pub struct NestedRefMut<'a, T, N>{ /* private fields */ }
Expand description
Exclusive reference to data contained in one or more nested RefCell
s.
This has the same interface as RefMut
, and unlike NestedRef
cannot be
nested further.
§Examples
// Create a `RefCell` two levels deep and a `NestedRefMut` into it
let rc = RefCell::new(RefCell::new(0));
let nr = NestedRef::new(rc.borrow());
let mut nr = NestedRef::map_ref_mut(nr, RefCell::borrow_mut);
// Mutate contained value
assert_eq!(*nr, 0);
*nr = 1;
assert_eq!(*nr, 1);
Implementations§
Source§impl<'a, T> NestedRefMut<'a, T, U0>where
T: ?Sized,
impl<'a, T> NestedRefMut<'a, T, U0>where
T: ?Sized,
Source§impl<'a, T, N> NestedRefMut<'a, T, N>
impl<'a, T, N> NestedRefMut<'a, T, N>
Sourcepub fn map<U, F>(orig: Self, f: F) -> NestedRefMut<'a, U, N>
pub fn map<U, F>(orig: Self, f: F) -> NestedRefMut<'a, U, N>
Creates a reference to a component of the borrowed data, like RefMut::map
.
This is an associated function, because a method would interfere with methods of the same
name on the contents of the RefCell
.
Sourcepub fn filter_map<U, F>(
orig: Self,
f: F,
) -> Result<NestedRefMut<'a, U, N>, Self>
pub fn filter_map<U, F>( orig: Self, f: F, ) -> Result<NestedRefMut<'a, U, N>, Self>
Creates a reference to an optional component of the borrowed data, like
RefMut::filter_map
. The original reference is returned inside an Err
if the closure
returns None
.
This is an associated function, because a method would interfere with methods of the same
name on the contents of the RefCell
.
Sourcepub fn map_split<U, V, F>(
orig: Self,
f: F,
) -> (NestedRefMut<'a, U, N>, NestedRefMut<'a, V, N>)
pub fn map_split<U, V, F>( orig: Self, f: F, ) -> (NestedRefMut<'a, U, N>, NestedRefMut<'a, V, N>)
Splits a reference into multiple references for different components of the borrowed data,
like RefMut::map_split
.
This is an associated function, because a method would interfere with methods of the same
name on the contents of the RefCell
.