8 ms·
> 1. I’m sure Rust people really hate this idea. Rust has unsized types, like slices. Such types can't be passed by value and pointers to such types consist of
by CodesInChaos 5y ago
> 1. I’m sure Rust people really hate this idea.
Rust has unsized types, like slices. Such types can't be passed by value and pointers to such types consist of two words (address and length for slices). You can put an unsized type at the end of a struct, resulting in an unsized struct. Using a slice as the last member is equivalent to a flexible array member in C.
Unfortunately they're barely usable in the current state, since there is no good way to construct such a struct.
- SV_BubbleTime 5y ago>You can put an unsized type at the end of a struct, resulting in an unsized struct. Using a slice as the last member is equivalent to a flexible array member in C. News to me! I figured it was inherently a little "unsafe" and Rust's thing in mem safety. Good to know! >Unfortunately they're barely usable in the current state, since there is no good way to construct such a struct. Ok, well, now that's just bizarre, but I assume there is a good reason. I'll get on Rust when it's "official" somewhere for embedded. Until then, a strange and mystical shadow in the forest for me.