SpezEmpty

Struct SpezEmpty 

Source
pub struct SpezEmpty<T: ?Sized>(/* private fields */);
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.

Unlike Spez, SpezEmpty wraps a type instead of a value. It is used in conjunction with trait implementations that leverage Rust’s method resolution rules to select different implementations based on available traits.

Implementations§

Source§

impl<T: ?Sized> SpezEmpty<T>

Source

pub const SPEZ: Self

An instance of SpezEmpty.

Trait Implementations§

Source§

impl<T: ?Sized> SpezDefaultInPlaceNo for SpezEmpty<T>

Source§

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

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

impl<T: Default> SpezDefaultInPlaceYes for &SpezEmpty<T>

Source§

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

Creates a default value for the inner type in place. Read more
Source§

impl<T: ?Sized> SpezParseNo for SpezEmpty<T>

Source§

unsafe fn spez_parse( &self, _s: &str, _target: PtrUninit, ) -> Result<PtrMut, ParseError>

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

impl<T: FromStr> SpezParseYes for &SpezEmpty<T>

Source§

unsafe fn spez_parse( &self, s: &str, target: PtrUninit, ) -> Result<PtrMut, ParseError>

Parses a string slice into the inner type. Read more

Auto Trait Implementations§

§

impl<T> Freeze for SpezEmpty<T>
where T: ?Sized,

§

impl<T> RefUnwindSafe for SpezEmpty<T>
where T: ?Sized,

§

impl<T> Send for SpezEmpty<T>
where T: ?Sized,

§

impl<T> Sync for SpezEmpty<T>
where T: ?Sized,

§

impl<T> Unpin for SpezEmpty<T>
where T: ?Sized,

§

impl<T> UnwindSafe for SpezEmpty<T>
where T: ?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.