Implement (part of) ACP 429: add DerefMut
to Lazy[Cell/Lock]
by ChayimFriedman2 · Pull Request #129334 · rust-lang/rust (original) (raw)
Getting this old request on the radar:
@rustbot label +I-libs-api-nominated
If this is accepted then it likely makes sense to stabilize force_mut
at the same time, since DerefMut
exposes that behavior (above discussion is outdated, this method now exists as unstable).
impl<T, F: FnOnce() -> T> DerefMut for LazyCell<T, F> { /* ... / } impl<T, F: FnOnce() -> T> DerefMut for LazyLock<T, F> { / ... */ }
impl<T, F> core::cell::LazyCell<T, F> { pub fn force_mut(this: &mut Self) -> &mut T; } impl<T, F> std::sync::LazyLock<T, F> { pub fn force_mut(this: &mut Self) -> &mut T; }
force_mut
's tracking issue at #129333 has a couple of other methods.