I want to initialize an array whose length is equal to another array's length:
fn foo(array: &[i32]) {
let mut sum = [0; array.len()];
}
It will make an error:
error[E0080]: constant evaluation error
--> test.rs:22:18
|
22 | let mut sum = [0; array.len()];
| ^^^^^^^^^^^ unsupported constant expr
I think I must use this len()
argument... How can I solve this?