Oh and .clone()
Follow up of: “Mmm… should I put lifecycle annotation in these 10 structs or just use and Rc and call it a day?”. Rc and Box FTW.
Hahaha yes tfw Rust forces you to put your shit in a
>
New your program deadlocks instead of crashing, peak safety.
EVERYBODY STOP. Nobody make a move or the memory dies. We have a Mexican Memory Standoff.
I think that’s the only thing I dislike about rust. Not having to use * to dereference but later having to use is tad confusing. I know it’s still clever solution but in this case I prefer c++'s straightforward consistency.
Using ampersand never was problematic for me.
C++ does have the problem that references are not objects, which introduces many subtle issues. For example, you cannot use a type like
std::vector
, so that templated code will often have to invokestd::remove_reference
and so on. Rust opts for a more consistent data model, but then introduces auto-deref (and the Deref trait) to get about the same usability C++ has with references andoperator->
. Note that C++ will implicitly chainoperator->
calls until a plain pointer is reached, whereas Rust will stop dereferencing once a type with a matching method/field is found. Having deep knowledge of both languages, I’m not convinced that C++ features “straightforward consistency” here…
I thought it was randomly adding Send and Sync traits to function signatures until rustc is happy.
That too