Struct dereffer::DerefsToMut

source ·
pub struct DerefsToMut<Inner, Ref: ?Sized> { /* private fields */ }
Expand description

Similar to DerefsTo, but supports mutable dereferencing too.

Because Ruse doesn’t offer a way to abstract over mutability, i.e., accept both &T and &mut T, this struct must handle the Deref and DerefMut cases separately with individual functions.

Implementations§

source§

impl<Inner, Ref: ?Sized> DerefsToMut<Inner, Ref>

source

pub const fn new( inner: Inner, deref_func: fn(_: &Inner) -> &Ref, deref_mut_func: fn(_: &mut Inner) -> &mut Ref ) -> Self

Creates a new wrapper with custom arbitrary deref functions.

source§

impl<Inner, Ref> DerefsToMut<Inner, Ref>where Inner: DerefMut<Target = Ref>, Ref: ?Sized,

source

pub const fn new_default(inner: Inner) -> Self

Creates a new wrapper with default, simple deref functions, Deref::deref() and DerefMut::deref_mut().

Trait Implementations§

source§

impl<Inner, Ref: ?Sized> Deref for DerefsToMut<Inner, Ref>

§

type Target = Ref

The resulting type after dereferencing.
source§

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

Dereferences the value.
source§

impl<Inner, Ref: ?Sized> DerefMut for DerefsToMut<Inner, Ref>

source§

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

Mutably dereferences the value.

Auto Trait Implementations§

§

impl<Inner, Ref: ?Sized> RefUnwindSafe for DerefsToMut<Inner, Ref>where Inner: RefUnwindSafe,

§

impl<Inner, Ref: ?Sized> Send for DerefsToMut<Inner, Ref>where Inner: Send,

§

impl<Inner, Ref: ?Sized> Sync for DerefsToMut<Inner, Ref>where Inner: Sync,

§

impl<Inner, Ref: ?Sized> Unpin for DerefsToMut<Inner, Ref>where Inner: Unpin,

§

impl<Inner, Ref: ?Sized> UnwindSafe for DerefsToMut<Inner, Ref>where Inner: UnwindSafe,

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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<T, U> TryFrom<U> for Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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.