r/rust • u/rustacean1337 • Nov 17 '22
What are Rust’s biggest weaknesses?
What would you say are Rust’s biggest weaknesses right now? And are they things that can be fixed in future versions do you think or is it something that could only be fixed by introducing a breaking change? Let’s say if you could create a Rust 2.0 and therefore not worry about backwards compatibility what would you do different.
220
Upvotes
View all comments
Show parent comment
1
u/phazer99 Nov 18 '22
I've never used
try_borrow()in my code because in general incorrect borrowing is a code bug, not an error you should/can recover from. To avoid as many runtime borrowing bugs as possible, I always useCellinstead ofRefCellwhenever possible, try to minimize the amount of data I wrap in aRefCelland also borrow it for as short time as possible.For example instead of:
I would write:
This also gives other benefits like being able to create
Playermethods that takesself: &Rc<Player>as first parameter (self: &Rc<RefCell<Player>>doesn't work).