Re:Rust: Dropping heavy things in another thread can make yo...
by wnoise on Saturday May 30, 2020 @04:02PM
(#23364155)
> which is why Rust deals very badly with graphs, and more generally any situation where ownership is unclear
To be fair, so do 90+% of programmers. Much of rust's benefit in safe code is training programmers to avoid code like that where possible, and spreading design patterns that avoid it.
Rust is based on ownership and statically checked move semantics (by default though can be opted out). So each item has a single owner (which is why Rust deals very badly with graphs, and more generally any situation where ownership is unclear) and the compiler will prevent you from using a moved object (unlike C++).
Separately it has a smart pointer which is the dual of unique_ptr (Box), with the guarantee noted above:
will not compile because the second line moves the box, after which it can't be used because it's been removed entirely from this scope.