CARDIAC › rust-cardiac › Message codes › RCE0020
RCE0020error
An array passed by value that isn't a local.
error[RCE0020]: call to {callee}: an array passed by value must be a local array; pass it by reference, `&[T; N]`
An array passed by value that isn't a local array of the caller's.
An array passed by value is copied, element by element, from the caller's array into the function's. The compiler copies from a local array; an array that is a constant, a field, or the result of an expression has to be a local first.
Pass it by reference, which copies nothing, or put it in a local first.
fn total(t: &[i16; 4]) -> i16 { t[0] + t[1] + t[2] + t[3] }
let s = total(&[1, 2, 3, 4]);
In a terminal: cargo cardiac help RCE0020.