I get why they must have constant size, but I don't get why that size must be known at compile time. Even C allows variable length arrays on the stack. What does this limitation help Rust with?
3
votes
1 Answers
4
votes
Even C allows variable length arrays on the stack.
C can relatively easily support this because of its trivial semantics.
When you have to call destructors/drop, this is far less trivial, so Rust didn't initially support it because it's effort to implement and doesn't give all that much of a benefit.
Eventually, Rust will support this (and already does on nightly) thanks to RFC 1909 — unsized rvalues.
let ref a: Trait = Structforbidden?; What does “Sized is not implemented” mean? - Shepmaster