pub struct RefMut<'a, T, U = T>{ /* private fields */ }Expand description
A wrapper type for a mutably borrowed value from a GcCell<T>.
Implementations§
Source§impl<'a, T, U> GcCellRefMut<'a, T, U>
impl<'a, T, U> GcCellRefMut<'a, T, U>
Sourcepub fn map<V, F>(orig: GcCellRefMut<'a, T, U>, f: F) -> GcCellRefMut<'a, T, V>
pub fn map<V, F>(orig: GcCellRefMut<'a, T, U>, f: F) -> GcCellRefMut<'a, T, V>
Makes a new GcCellRefMut for a component of the borrowed data, e.g., an enum
variant.
The GcCellRefMut is already mutably borrowed, so this cannot fail.
This is an associated function that needs to be used as
GcCellRefMut::map(...). A method would interfere with methods of the same
name on the contents of a GcCell used through Deref.
§Examples
use gc::{GcCell, GcCellRefMut};
let c = GcCell::new((5, 'b'));
{
let b1: GcCellRefMut<(u32, char)> = c.borrow_mut();
let mut b2: GcCellRefMut<(u32, char), u32> = GcCellRefMut::map(b1, |t| &mut t.0);
assert_eq!(*b2, 5);
*b2 = 42;
}
assert_eq!(*c.borrow(), (42, 'b'));Trait Implementations§
Source§impl<'a, T, U> Debug for GcCellRefMut<'a, T, U>
impl<'a, T, U> Debug for GcCellRefMut<'a, T, U>
Source§impl<'a, T, U> Deref for GcCellRefMut<'a, T, U>
impl<'a, T, U> Deref for GcCellRefMut<'a, T, U>
Source§impl<'a, T, U> DerefMut for GcCellRefMut<'a, T, U>
impl<'a, T, U> DerefMut for GcCellRefMut<'a, T, U>
Source§impl<'a, T, U> Display for GcCellRefMut<'a, T, U>
impl<'a, T, U> Display for GcCellRefMut<'a, T, U>
Auto Trait Implementations§
impl<'a, T, U> Freeze for GcCellRefMut<'a, T, U>
impl<'a, T, U = T> !RefUnwindSafe for GcCellRefMut<'a, T, U>
impl<'a, T, U = T> !Send for GcCellRefMut<'a, T, U>
impl<'a, T, U = T> !Sync for GcCellRefMut<'a, T, U>
impl<'a, T, U> Unpin for GcCellRefMut<'a, T, U>
impl<'a, T, U = T> !UnwindSafe for GcCellRefMut<'a, T, U>
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