Struct proc_macro::bridge::scoped_cell::ScopedCell
source · pub struct ScopedCell<T: LambdaL>(Cell<<T as ApplyL<'static>>::Out>);
🔬This is a nightly-only experimental API. (
proc_macro_internals
#27812)Tuple Fields§
§0: Cell<<T as ApplyL<'static>>::Out>
🔬This is a nightly-only experimental API. (
proc_macro_internals
#27812)Implementations§
source§impl<T: LambdaL> ScopedCell<T>
impl<T: LambdaL> ScopedCell<T>
pub const fn new(value: <T as ApplyL<'static>>::Out) -> Self
🔬This is a nightly-only experimental API. (
proc_macro_internals
#27812)sourcepub fn replace<'a, R>(
&self,
replacement: <T as ApplyL<'a>>::Out,
f: impl for<'b, 'c> FnOnce(RefMutL<'b, 'c, T>) -> R
) -> R
🔬This is a nightly-only experimental API. (proc_macro_internals
#27812)
pub fn replace<'a, R>( &self, replacement: <T as ApplyL<'a>>::Out, f: impl for<'b, 'c> FnOnce(RefMutL<'b, 'c, T>) -> R ) -> R
proc_macro_internals
#27812)Sets the value in self
to replacement
while
running f
, which gets the old value, mutably.
The old value will be restored after f
exits, even
by panic, including modifications made to it by f
.
Auto Trait Implementations§
impl<T> !RefUnwindSafe for ScopedCell<T>
impl<T> Send for ScopedCell<T>where <T as ApplyL<'static>>::Out: Send,
impl<T> !Sync for ScopedCell<T>
impl<T> Unpin for ScopedCell<T>where <T as ApplyL<'static>>::Out: Unpin,
impl<T> UnwindSafe for ScopedCell<T>where <T as ApplyL<'static>>::Out: UnwindSafe,
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more