Spez

Struct Spez 

Source
#[repr(transparent)]
pub struct Spez<T: ?Sized>(pub T);
Expand description

A wrapper type used for auto-deref specialization.

This struct is a core part of the auto-deref-based specialization technique which allows conditionally implementing functionality based on what traits a type implements, without requiring the unstable specialization feature.

It wraps a value and is used in conjunction with trait implementations that leverage Rust’s method resolution rules to select different implementations based on available traits.

Tuple Fields§

§0: T

Trait Implementations§

Source§

impl<T: ?Sized> SpezCloneIntoNo for Spez<T>

Source§

unsafe fn spez_clone_into(&self, _target: PtrUninit) -> PtrMut

Fallback implementation when the type doesn’t implement Clone. Read more
Source§

impl<T: Clone> SpezCloneIntoYes for &Spez<&T>

Source§

unsafe fn spez_clone_into(&self, target: PtrUninit) -> PtrMut

Clones the inner value into the provided uninitialized memory. Read more
Source§

impl<T: ?Sized> SpezDebugNo for Spez<T>

Source§

fn spez_debug(&self, _f: &mut Formatter<'_>) -> Result<(), Error>

Fallback implementation when the type doesn’t implement Debug. Read more
Source§

impl<T: ?Sized + Debug> SpezDebugYes for &Spez<T>

Source§

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

Delegates to the inner type’s Debug implementation. Read more
Source§

impl<T: ?Sized> SpezDisplayNo for Spez<T>

Source§

fn spez_display(&self, _f: &mut Formatter<'_>) -> Result<(), Error>

Fallback implementation when the type doesn’t implement Display. Read more
Source§

impl<T: ?Sized + Display> SpezDisplayYes for &Spez<T>

Source§

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

Delegates to the inner type’s Display implementation. Read more
Source§

impl<T: ?Sized> SpezHashNo for Spez<T>

Source§

fn spez_hash<H: Hasher>(&self, _state: &mut H)

Fallback implementation when the type doesn’t implement Hash. Read more
Source§

impl<T: ?Sized + Hash> SpezHashYes for &Spez<T>

Source§

fn spez_hash<H: Hasher>(&self, state: &mut H)

Hashes the inner value. Read more
Source§

impl<T: ?Sized> SpezOrdNo for Spez<T>

Source§

fn spez_cmp(&self, _other: &Self) -> Ordering

Fallback implementation when the type doesn’t implement Ord. Read more
Source§

impl<T: ?Sized + Ord> SpezOrdYes for &Spez<T>

Source§

fn spez_cmp(&self, other: &Self) -> Ordering

Compares two values for ordering. Read more
Source§

impl<T: ?Sized> SpezPartialEqNo for Spez<T>

Source§

fn spez_partial_eq(&self, _other: &Self) -> bool

Fallback implementation when the type doesn’t implement PartialEq. Read more
Source§

impl<T: ?Sized + PartialEq> SpezPartialEqYes for &Spez<T>

Source§

fn spez_partial_eq(&self, other: &Self) -> bool

Checks if two values are equal. Read more
Source§

impl<T: ?Sized> SpezPartialOrdNo for Spez<T>

Source§

fn spez_partial_cmp(&self, _other: &Self) -> Option<Ordering>

Fallback implementation when the type doesn’t implement PartialOrd. Read more
Source§

impl<T: ?Sized + PartialOrd> SpezPartialOrdYes for &Spez<T>

Source§

fn spez_partial_cmp(&self, other: &Self) -> Option<Ordering>

Compares two values for ordering. Read more

Auto Trait Implementations§

§

impl<T> Freeze for Spez<T>
where T: Freeze + ?Sized,

§

impl<T> RefUnwindSafe for Spez<T>
where T: RefUnwindSafe + ?Sized,

§

impl<T> Send for Spez<T>
where T: Send + ?Sized,

§

impl<T> Sync for Spez<T>
where T: Sync + ?Sized,

§

impl<T> Unpin for Spez<T>
where T: Unpin + ?Sized,

§

impl<T> UnwindSafe for Spez<T>
where T: UnwindSafe + ?Sized,

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