RefMut

Struct RefMut 

Source
pub struct RefMut<'a, Trait: ?Sized + DynTrait> { /* private fields */ }
Expand description

A mutable reference to a tinydyn trait object.

RefMut<dyn Trait> can call the &self and &mut self methods of Trait through its Deref impl.

Like &mut dyn Trait, this cannot be cloned or copied. It can, however, be reborrowed.

Prefer passing this around rather than calling deref_mut and passing around that reference

  • that would create a double pointer.

Implementations§

Source§

impl<'a, Trait: ?Sized + DynTrait> RefMut<'a, Trait>

Source

pub fn new<U>(r: &'a mut U) -> Self
where <<Trait as DynTrait>::Plain as PlainDyn>::LocalNewtype<U>: Implements<Trait>,

Upcasts this &mut U into a RefMut<dyn Trait> so long as U: Trait.

This builds a tinydyn vtable and references it in the returned RefMut.

Source§

impl<'a, Trait: ?Sized + DynTrait + 'a> RefMut<'a, Trait>

Source

pub fn as_ref<'b>(&'b self) -> Ref<'b, Trait>

Reborrow as a shared Ref with a smaller lifetime.

Since a RefMut isn’t Copy, this is needed to pass to a function expecting a Ref and regain access to the underlying RefMut after it’s done.

Source

pub fn as_mut<'b>(&'b mut self) -> RefMut<'b, Trait>
where 'a: 'b,

Reborrow as a RefMut with a smaller lifetime.

Since a RefMut isn’t Copy, this is needed to pass to a function expecting a RefMut and regain access to the underlying RefMut after it’s done.

Source

pub fn as_downcast_ptr<T>(&mut self) -> NonNull<T>

Downcasts this RefMut into a raw pointer of concrete type.

The pointer can accessed soundly for the lifetime of &mut self so long as self was constructed from a &mut T.

Source

pub fn metadata(&self) -> <Trait::Plain as PlainDyn>::Metadata

Gets the pointer metadata for this trait object.

Source§

impl<'a, Trait: ?Sized + DynTrait + Send + 'a> RefMut<'a, Trait>

Source

pub fn remove_send(self) -> RefMut<'a, Trait::RemoveSend>

Removes the Send bound from Trait, if any.

Source§

impl<'a, Trait: ?Sized + DynTrait + Sync + 'a> RefMut<'a, Trait>

Source

pub fn remove_sync(self) -> RefMut<'a, Trait::RemoveSync>

Removes the Sync bound from Trait, if any.

Trait Implementations§

Source§

impl<'a, Trait: ?Sized + DynTrait + 'a> Deref for RefMut<'a, Trait>

Source§

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

It’s not recommended to hold onto the result of this deref, as it creates a double reference.

Source§

type Target = DynTarget<Trait>

The resulting type after dereferencing.
Source§

impl<'a, Trait: ?Sized + DynTrait + 'a> DerefMut for RefMut<'a, Trait>

Source§

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

It’s not recommended to hold onto the result of this deref, as it creates a double reference.

Source§

impl<'a, Trait: ?Sized + DynTrait> From<RefMut<'a, Trait>> for Ref<'a, Trait>

Source§

fn from(value: RefMut<'a, Trait>) -> Self

Converts to this type from the input type.
Source§

impl<'a, Trait> Send for RefMut<'a, Trait>
where Trait: ?Sized + DynTrait, &'a mut Trait: Send,

Source§

impl<'a, Trait> Sync for RefMut<'a, Trait>
where Trait: ?Sized + DynTrait, &'a mut Trait: Sync,

Auto Trait Implementations§

§

impl<'a, Trait> Freeze for RefMut<'a, Trait>
where <<Trait as DynTrait>::Plain as PlainDyn>::Metadata: Freeze, Trait: ?Sized,

§

impl<'a, Trait> RefUnwindSafe for RefMut<'a, Trait>
where <<Trait as DynTrait>::Plain as PlainDyn>::Metadata: RefUnwindSafe, Trait: RefUnwindSafe + ?Sized,

§

impl<'a, Trait> Unpin for RefMut<'a, Trait>
where <<Trait as DynTrait>::Plain as PlainDyn>::Metadata: Unpin, Trait: ?Sized,

§

impl<'a, Trait> !UnwindSafe for RefMut<'a, Trait>

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.