I am trying to return the values of a vector:
fn merge<'a>(left: &'a [i32], right: &'a [i32]) -> [i32] {
let mut merged: Vec<i32> = Vec::new();
// push elements to merged
*merged
}
I get the error message:
error[E0277]: the size for values of type `[i32]` cannot be known at compilation time
--> src/lib.rs:1:52
|
1 | fn merge<'a>(left: &'a [i32], right: &'a [i32]) -> [i32] {
| ^^^^^ doesn't have a size known at compile-time
|
= help: the trait `std::marker::Sized` is not implemented for `[i32]`
= note: to learn more, visit <https://doc.rust-lang.org/book/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait>
= note: the return type of a function must have a statically known size
I can't find out how to fix this.
See Question&Answers more detail:os