3 ms·
I know that proposing Rust in this case almost became a cliché but Rust's borrowing mechanism introduces such a semantic and ensures correctness in compile time
by maemre 12y ago
I know that proposing Rust in this case almost became a cliché but Rust's borrowing mechanism introduces such a semantic and ensures correctness in compile time. Moreover, with RAII it can also zero the memory after object is out of scope.
- doomrobo 12y agoWell, only for Box<> pointers, but yes
- masklinn 12y agoOwnership is for all structures on the stack. Box is little more than a rust-level wrapper around a raw pointer (well technically around a core::ptr::Unique which is the actual wrapper around a raw pointer)
- dbaupp 12y agoWhich part are you referring to with "only"? There's nothing particularly special about Box, at least, not in relation to the things the parent mentioned.
- doomrobo 12y agoWhoops, misread "zero" as "deallocate". I meant that Box<> pointers are heap-allocated but deallocated when they go out of scope.
- mtanski 12y agoExcept when escape out to unsafe (as a lot of rust code does) or stop using rust because the borrow checker is brain dead: https://github.com/rust-lang/rust/issues/6268 https://github.com/rust-lang/rust/issues/6268 https://github.com/rust-lang/rust/issues/6393 https://github.com/rust-lang/rust/issues/6393 Those bugs are 2 years old. And heaven forbid you have &mut self in a object.