Tracking Issue for std::cell::{Ref, RefMut}::leak (original) (raw)
#68712 adds methods to convert RefCell guards Ref/RefMut into references with the lifetime of the underlying cell.
The feature gate for the issue is #![feature(cell_leak)].
Unresolved Questions
- Should similar methods be provided for
MutexGuardandRwLockReadGuard/RwLockWriteGuard? (Add methods to 'leak' RefCell borrows as references with the lifetime of the original reference #68712 (comment)) - Should
unsafemethods be added to forcefully revert a leak? (Add undo_leak to reset RefCell borrow state #69528 (review))- Uses cases include situations where you can not keep the guard (Tracking Issue for std::cell::{Ref, RefMut}::leak #69099 (comment)), it'd be more flexible if they did not require a leak of the resource until the next uniqe / &mut reference to the cell.
- For
undo_leak, would it make more sense not to return a reference (i.e., separate this fromget_mut)? (Add undo_leak to reset RefCell borrow state #69528 (comment))