Open
Description
What it does
On this code:
use std::cell::RefCell;
pub fn foo(x: &mut RefCell<i32>) {
*x.borrow_mut() += 1;
}
the lint would suggest to use get_mut()
rather than borrow_mut()
. (Same for borrow()
, of course.)
Lint Name
unnecessary_runtime_borrow
Category
perf
Advantage
- Removes unnecessary run-time borrow tracking of
RefCell
Drawbacks
None that I know if
Example
See above.
Mutex
and RwLock
also have get_mut
functions, so the same kind of lint could be added for them.