Struct ReborrowMut

Source
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>

Source

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

See TokenRefCell::borrow_mut.

Source

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.

See TokenRefCell::try_borrow_mut.

Source

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

See TokenRefCell::borrow_mut.

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    }
Source

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.

See TokenRefCell::try_borrow_mut.

Source

pub fn token_id(&self) -> Tk::Id

Get the id of the borrowed token.

Trait Implementations§

Source§

impl<S: ?Sized + Debug, Tk: Token + ?Sized> Debug for ReborrowMut<'_, S, Tk>
where Tk::Id: Debug,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<S: ?Sized, Tk: Token + ?Sized> Deref for ReborrowMut<'_, S, Tk>

Source§

type Target = S

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl<S: ?Sized, Tk: Token + ?Sized> DerefMut for ReborrowMut<'_, S, Tk>

Source§

fn deref_mut(&mut self) -> &mut Self::Target

Mutably dereferences the value.

Auto Trait Implementations§

§

impl<'b, S, Tk> Freeze for ReborrowMut<'b, S, Tk>
where <Tk as Token>::Id: Freeze, S: Freeze + ?Sized, Tk: ?Sized,

§

impl<'b, S, Tk> RefUnwindSafe for ReborrowMut<'b, S, Tk>
where <Tk as Token>::Id: RefUnwindSafe, S: RefUnwindSafe + ?Sized, Tk: RefUnwindSafe + ?Sized,

§

impl<'b, S, Tk> Send for ReborrowMut<'b, S, Tk>
where <Tk as Token>::Id: Send, S: Send + ?Sized, Tk: Send + ?Sized,

§

impl<'b, S, Tk> Sync for ReborrowMut<'b, S, Tk>
where <Tk as Token>::Id: Sync, S: Sync + ?Sized, Tk: Sync + ?Sized,

§

impl<'b, S, Tk> Unpin for ReborrowMut<'b, S, Tk>
where <Tk as Token>::Id: Unpin, S: Unpin + ?Sized, Tk: ?Sized,

§

impl<'b, S, Tk> !UnwindSafe for ReborrowMut<'b, S, Tk>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.