pub struct ManagedRefMut<T: ?Sized> { /* private fields */ }Expand description
Exclusive handle to a value owned by a Managed, the runtime &mut T.
Can be reborrowed, both shared and exclusive, one level deeper.
Implementations§
Source§impl<T: ?Sized> ManagedRefMut<T>
impl<T: ?Sized> ManagedRefMut<T>
Sourcepub fn new(data: &mut T, lifetime: LifetimeRefMut) -> Self
pub fn new(data: &mut T, lifetime: LifetimeRefMut) -> Self
Pairs a mutable reference with an exclusive borrow of its lifetime.
Sourcepub unsafe fn new_raw(data: *mut T, lifetime: LifetimeRefMut) -> Option<Self>
pub unsafe fn new_raw(data: *mut T, lifetime: LifetimeRefMut) -> Option<Self>
ManagedRefMut::new over a raw pointer. A null pointer yields
None.
§Safety
data must stay valid and unaliased for as long as lifetime says it
does, and lifetime must be the borrow state that guards it.
Sourcepub fn make(data: &mut T) -> (Self, Lifetime)
pub fn make(data: &mut T) -> (Self, Lifetime)
Builds a handle to a plain mutable reference along with the lifetime that backs it.
The caller has to keep the returned Lifetime alive for at least as
long as the handle.
Sourcepub unsafe fn make_raw(data: *mut T) -> Option<(Self, Lifetime)>
pub unsafe fn make_raw(data: *mut T) -> Option<(Self, Lifetime)>
ManagedRefMut::make over a raw pointer.
§Safety
data must stay valid and unaliased for as long as the returned handle
lives.
Sourcepub fn into_inner(self) -> (LifetimeRefMut, *mut T)
pub fn into_inner(self) -> (LifetimeRefMut, *mut T)
Splits into the borrow token and the pointer.
Sourcepub fn into_dynamic(self) -> DynamicManagedRefMut
pub fn into_dynamic(self) -> DynamicManagedRefMut
Erases the type, keeping the same claim.
Sourcepub fn lifetime(&self) -> &LifetimeRefMut
pub fn lifetime(&self) -> &LifetimeRefMut
Returns the borrow token.
Sourcepub fn borrow(&self) -> Option<ManagedRef<T>>
pub fn borrow(&self) -> Option<ManagedRef<T>>
Takes a shared handle nested under this one.
Sourcepub fn borrow_mut(&mut self) -> Option<ManagedRefMut<T>>
pub fn borrow_mut(&mut self) -> Option<ManagedRefMut<T>>
Takes an exclusive handle nested under this one.
Sourcepub fn lazy(&self) -> ManagedLazy<T>
pub fn lazy(&self) -> ManagedLazy<T>
Takes an unclaimed handle.
Sourcepub fn read(&self) -> Option<ValueReadAccess<'_, T>>
pub fn read(&self) -> Option<ValueReadAccess<'_, T>>
Guards the value for reading, or returns None when it is written or
the owner is gone.
Sourcepub fn write(&mut self) -> Option<ValueWriteAccess<'_, T>>
pub fn write(&mut self) -> Option<ValueWriteAccess<'_, T>>
Guards the value for writing, or returns None when it is accessed or
the owner is gone.
Sourcepub unsafe fn map<U>(self, f: impl FnOnce(&mut T) -> &mut U) -> ManagedRefMut<U>
pub unsafe fn map<U>(self, f: impl FnOnce(&mut T) -> &mut U) -> ManagedRefMut<U>
Narrows this handle down to a part of the value, such as one field.
§Safety
f must return a reference into the same value, and the owner must
still be alive.
Sourcepub unsafe fn try_map<U>(
self,
f: impl FnOnce(&mut T) -> Option<&mut U>,
) -> Option<ManagedRefMut<U>>
pub unsafe fn try_map<U>( self, f: impl FnOnce(&mut T) -> Option<&mut U>, ) -> Option<ManagedRefMut<U>>
Sourcepub unsafe fn as_ptr(&self) -> Option<*const T>
pub unsafe fn as_ptr(&self) -> Option<*const T>
Returns the pointer while the owner is alive, bypassing access checks.
§Safety
The caller takes over checking for conflicting access.
Sourcepub unsafe fn as_mut_ptr(&mut self) -> Option<*mut T>
pub unsafe fn as_mut_ptr(&mut self) -> Option<*mut T>
Returns the mutable pointer while the owner is alive, bypassing access checks.
§Safety
The caller takes over checking for conflicting access.