If I write a function that takes one argument of type [f32]
(as opposed to e.g. &[f32]
), I get an error:
the trait bound `[f32]: std::marker::Sized` is not satisfied
The docs say this is because [f32]
does not have a compile-time-known size. A reasonable limitation. Fair enough.
However, there is at least one function in the standard library with this type. Here's me calling it:
let b: Box<[f32]> = Box::new([1.0, 2.0, 3.0]);
How come this is allowed in the standard library and not in my code? What is the relevant difference? (There's no obvious magic in the source).
b
. Does that not determine the type at which Box is instantiated? – Farro