Closed
Description
Given the following code:
fn process_slice(data: &[i32]) {
todo!()
}
fn main() {
let some_generated_vec = (0..10).collect();
process_slice(&some_generated_vec);
}
The current output is:
Compiling playground v0.0.1 (/playground)
error[E0277]: the size for values of type `[i32]` cannot be known at compilation time
--> src/main.rs:6:9
|
6 | let some_generated_vec = (0..10).collect();
| ^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
|
= help: the trait `Sized` is not implemented for `[i32]`
= note: all local variables must have a statically known size
= help: unsized locals are gated as an unstable feature
error[E0277]: a value of type `[i32]` cannot be built from an iterator over elements of type `{integer}`
--> src/main.rs:6:38
|
6 | let some_generated_vec = (0..10).collect();
| ^^^^^^^ value of type `[i32]` cannot be built from `std::iter::Iterator<Item={integer}>`
|
= help: the trait `FromIterator<{integer}>` is not implemented for `[i32]`
note: required by a bound in `collect`
I am not sure what the ideal output would be here, but currently it suggests that collect
wants to build an array of a specific size, which hasn't been specified.