pub struct RefMut<'a, T: ?Sized> { /* private fields */ }Expand description
Exclusive (mutable) borrow guard for account data.
On drop, restores RuntimeAccount.borrow_state to NOT_BORROWED.
Implementations§
Source§impl<'a, T: ?Sized> RefMut<'a, T>
impl<'a, T: ?Sized> RefMut<'a, T>
Sourcepub fn map<U: ?Sized>(
orig: Self,
f: impl FnOnce(&mut T) -> &mut U,
) -> RefMut<'a, U>
pub fn map<U: ?Sized>( orig: Self, f: impl FnOnce(&mut T) -> &mut U, ) -> RefMut<'a, U>
Narrow an exclusive guard without releasing its account borrow.
Sourcepub fn try_map<U: ?Sized, E>(
orig: Self,
f: impl FnOnce(&mut T) -> Result<&mut U, E>,
) -> Result<RefMut<'a, U>, (Self, E)>
pub fn try_map<U: ?Sized, E>( orig: Self, f: impl FnOnce(&mut T) -> Result<&mut U, E>, ) -> Result<RefMut<'a, U>, (Self, E)>
Narrow a guard, preserving the original guard on an error. A closure may itself mutate data before returning an error; those edits are retained.
Sourcepub fn filter_map<U: ?Sized>(
orig: Self,
f: impl FnOnce(&mut T) -> Option<&mut U>,
) -> Result<RefMut<'a, U>, Self>
pub fn filter_map<U: ?Sized>( orig: Self, f: impl FnOnce(&mut T) -> Option<&mut U>, ) -> Result<RefMut<'a, U>, Self>
Narrow a guard, returning the original guard if the field is absent.
Sourcepub unsafe fn from_raw_parts(value: &'a mut T, state: *mut u8) -> Self
pub unsafe fn from_raw_parts(value: &'a mut T, state: *mut u8) -> Self
Create an exclusive borrow guard from raw parts.
§Safety
The caller must ensure:
- The borrow state at
statewas set to 0 (exclusive) valueis valid and unique for lifetime'astatepoints to a validRuntimeAccount.borrow_state
Sourcepub fn into_raw_parts(self) -> (&'a mut T, *mut u8)
pub fn into_raw_parts(self) -> (&'a mut T, *mut u8)
Decompose into raw parts without running the destructor.
The caller takes responsibility for eventually releasing the
borrow (restoring *state to NOT_BORROWED).
Trait Implementations§
Auto Trait Implementations§
impl<'a, T> !Send for RefMut<'a, T>
impl<'a, T> !Sync for RefMut<'a, T>
impl<'a, T> !UnwindSafe for RefMut<'a, T>
impl<'a, T> Freeze for RefMut<'a, T>
impl<'a, T> RefUnwindSafe for RefMut<'a, T>
impl<'a, T> Unpin for RefMut<'a, T>
impl<'a, T> UnsafeUnpin for RefMut<'a, T>
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