pub struct ReborrowMut<'b, S: ?Sized, Tk: Token + ?Sized> { /* private fields */ }
Expand description
Stateful wrapper around a borrowed token exclusive reference.
Implementations§
Source§impl<S: ?Sized, Tk: Token + ?Sized> ReborrowMut<'_, S, Tk>
impl<S: ?Sized, Tk: Token + ?Sized> ReborrowMut<'_, S, Tk>
Sourcepub fn reborrow_mut<U: ?Sized>(
&mut self,
cell: impl FnOnce(&mut S) -> &TokenRefCell<U, Tk>,
) -> RefMut<'_, U, Tk>
pub fn reborrow_mut<U: ?Sized>( &mut self, cell: impl FnOnce(&mut S) -> &TokenRefCell<U, Tk>, ) -> RefMut<'_, U, Tk>
Uses borrowed token exclusive reference to reborrow a TokenRefCell
.
§Panics
Sourcepub fn try_reborrow_mut<U: ?Sized>(
&mut self,
cell: impl FnOnce(&mut S) -> &TokenRefCell<U, Tk>,
) -> Result<RefMut<'_, U, Tk>, BorrowMutError>
pub fn try_reborrow_mut<U: ?Sized>( &mut self, cell: impl FnOnce(&mut S) -> &TokenRefCell<U, Tk>, ) -> Result<RefMut<'_, U, Tk>, BorrowMutError>
Uses borrowed token exclusive reference to reborrow a TokenRefCell
.
Sourcepub fn reborrow_opt_mut<U: ?Sized>(
&mut self,
cell: impl FnOnce(&mut S) -> Option<&TokenRefCell<U, Tk>>,
) -> Option<RefMut<'_, U, Tk>>
pub fn reborrow_opt_mut<U: ?Sized>( &mut self, cell: impl FnOnce(&mut S) -> Option<&TokenRefCell<U, Tk>>, ) -> Option<RefMut<'_, U, Tk>>
Uses borrowed token exclusive reference to optionally reborrow a TokenRefCell
.
§Panics
Examples found in repository?
examples/graph.rs (line 47)
40 pub fn remove_node(&mut self, id: NodeId) -> bool {
41 let Some(node) = self.nodes.remove(&id) else {
42 return false;
43 };
44 let mut node_mut = node.borrow_mut(&mut self.token);
45 let mut reborrow_mut =
46 node_mut.reborrow_stateful_mut(|node| node.edges.values().map(AsRef::as_ref));
47 while let Some(mut other) = reborrow_mut.reborrow_opt_mut(|edges| edges.next()) {
48 other.edges.remove(&id);
49 }
50 true
51 }
Sourcepub fn try_reborrow_opt_mut<U: ?Sized>(
&mut self,
cell: impl FnOnce(&mut S) -> Option<&TokenRefCell<U, Tk>>,
) -> Option<Result<RefMut<'_, U, Tk>, BorrowMutError>>
pub fn try_reborrow_opt_mut<U: ?Sized>( &mut self, cell: impl FnOnce(&mut S) -> Option<&TokenRefCell<U, Tk>>, ) -> Option<Result<RefMut<'_, U, Tk>, BorrowMutError>>
Uses borrowed token exclusive reference to optionally reborrow a TokenRefCell
.
Trait Implementations§
Auto Trait Implementations§
impl<'b, S, Tk> Freeze for ReborrowMut<'b, S, Tk>
impl<'b, S, Tk> RefUnwindSafe for ReborrowMut<'b, S, Tk>
impl<'b, S, Tk> Send for ReborrowMut<'b, S, Tk>
impl<'b, S, Tk> Sync for ReborrowMut<'b, S, Tk>
impl<'b, S, Tk> Unpin for ReborrowMut<'b, S, Tk>
impl<'b, S, Tk> !UnwindSafe for ReborrowMut<'b, S, Tk>
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