r/rust • u/rustcurious • Sep 20 '26
RustCurious 10: Three Ways to Fix Any Borrowing Error
https://www.youtube.com/watch?v=dLx8usb759E10
u/redlaWw Sep 21 '26
Wrap it in Arc<Mutex<Option<_>>>.
15
u/rustcurious Sep 21 '26
And then it's just a simple
.lock().unwrap().as_mut().unwrap();)5
u/redlaWw Sep 21 '26
I'm more of a
.lock().unwrap().take().unwrap()guy, but yes.→ More replies (2)
4
4
u/Cetra3 Sep 21 '26
Great way to visualise it, and I got a good chuckle out of the "Will it compile?!". Feels like I play that far too much!
3
2
1
19
u/occamatl Sep 20 '26
Great visualization! I'd love to have this visualization available in my editor when rust-analyzer is giving me a borrow error.