Important announcement!
I have written some rust code and I don't immediately hate it. I have not, however, had to fight the borrow checker yet…
Important announcement!
I have written some rust code and I don't immediately hate it. I have not, however, had to fight the borrow checker yet…
I am making things easy for myself on this Rust journey by focusing on only using the most basic stuff
You know, like modules, workspaces, generics, interior mutability, declarative and procedural macros…
Finding that a lot of really useful Rust features are very thinly documented. `Arc::make_mut()` is an *incredibly* powerful feature that is barely discussed. I only discovered it as a passing mention in the `Cow` docs. Just this one method has shaved literally hundreds of lines off the code I'm writing…
Worse still, the `Arc` introductory notes actually go out of their way to warn that you can't obtain a mutable reference, and point users at `Mutex`, without mentioning this copy-on-write feature!
#rustlang
@jonathanhogg Absolutely not comparable `Arc<Mutex<>>` gives shared access to mutable content, `Arc::make_mut()` is clone-on-write, so you mutate ONLY the copy, changes not reflected anywhere else; all `Weak` pointers are invalidated.
@michalfita you’ll find that I didn’t say they were comparable, just that the latter is thinly documented. Copy-on-write was exactly the behaviour I needed and a Mutex was how I was hacking it first time round
@jonathanhogg OK, fine then.
Nice you discovered something you like in #Rust.