[][src]Struct gc::GcCellRefMut

pub struct GcCellRefMut<'a, T: Trace + ?Sized + 'static> { /* fields omitted */ }

A wrapper type for a mutably borrowed value from a GcCell<T>.

Implementations

impl<'a, T: Trace + ?Sized> GcCellRefMut<'a, T>[src]

pub fn map<U: ?Sized, F>(orig: Self, f: F) -> GcCellRefMut<'a, U> where
    U: Trace,
    F: FnOnce(&mut T) -> &mut U, 
[src]

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> = GcCellRefMut::map(b1, |t| &mut t.0);
    assert_eq!(*b2, 5);
    *b2 = 42;
}
assert_eq!(*c.borrow(), (42, 'b'));

Trait Implementations

impl<'a, T: Trace + ?Sized + Debug> Debug for GcCellRefMut<'a, T>[src]

impl<'a, T: Trace + ?Sized> Deref for GcCellRefMut<'a, T>[src]

type Target = T

The resulting type after dereferencing.

impl<'a, T: Trace + ?Sized> DerefMut for GcCellRefMut<'a, T>[src]

impl<'a, T: Trace + ?Sized + Display> Display for GcCellRefMut<'a, T>[src]

impl<'a, T: Trace + ?Sized> Drop for GcCellRefMut<'a, T>[src]

Auto Trait Implementations

impl<'a, T> !RefUnwindSafe for GcCellRefMut<'a, T>

impl<'a, T> !Send for GcCellRefMut<'a, T>

impl<'a, T> !Sync for GcCellRefMut<'a, T>

impl<'a, T: ?Sized> Unpin for GcCellRefMut<'a, T>

impl<'a, T> !UnwindSafe for GcCellRefMut<'a, T>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.