SQ in silver chrome letters, a lab's gear stacked against the S: a rack, two oscilloscopes, pizza boxes and a six-pack. Strange Query Lab

CARDIAC › rust-cardiac › Message codes › RCE0040

RCE0040error

A slice the compiler can't follow.

error[RCE0040]: slices aren't supported: pass an array by reference, `&[i16; N]` ({why})

A slice (&[T]) used in a way the compiler can't compile.

A slice is an address and a length. The compiler compiles many slices (of an array, passed to a function, its length and its elements), but not every use the standard library makes of one.

Pass the array by reference, &[i16; N], whose length is part of its type.

fn total(t: &[i16; 8]) -> i16 {
    let mut s = 0;
    for i in 0..8 { s += t[i]; }
    s
}

In a terminal: cargo cardiac help RCE0040.