2 ms·
Very good article, and these types are essential to have in your Rust "vocabulary". I've seen programmers fight the borrow checker a fight they can't win, beca
by pornel 4y ago
Very good article, and these types are essential to have in your Rust "vocabulary".
I've seen programmers fight the borrow checker a fight they can't win, because `Arc<Mutex<Object>>` has a non-zero overhead and looks uglier than a plain `Object` or `&Object`. However, if the program has object lifetimes that aren't statically known and/or shared mutable state, these are simply the correct types to use (e.g. event-based systems that can attach listeners have to use these). Rust is just being very explicit about ownership and putting all overheads in your face. In something like Python there's no extra syntax for this, because every object is automatically under a lock and has a refcount.