Struct PhantomInvariant

#[repr(transparent)]
pub struct PhantomInvariant<T>(pub(in ::marker::variance) PhantomData<fn(T) -> T>)
where
    T: ?Sized,;

Zero-sized type used to mark a type parameter as invariant.

Types that are both passed as an argument and used as part of the return value from a function are invariant. See the reference for more information.

Layout

For all T, the following are guaranteed:

Fields

0: PhantomData<fn(T) -> T>

Implementations

impl<T> PhantomInvariant<T> where T: ?Sized,

const fn new() -> Self

Constructs a new instance of the variance marker.

Trait Implementations

impl<T> Clone for PhantomInvariant<T> where T: ?Sized,

fn clone(&self) -> Self

impl<T> Copy for PhantomInvariant<T> where T: ?Sized,

impl<T> Debug for PhantomInvariant<T> where T: ?Sized,

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

impl<T> Default for PhantomInvariant<T> where T: ?Sized,

fn default() -> Self

impl<T> Eq for PhantomInvariant<T> where T: ?Sized,

impl<T> Hash for PhantomInvariant<T> where T: ?Sized,

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

impl<T> Ord for PhantomInvariant<T> where T: ?Sized,

fn cmp(&self, &Self) -> Ordering

impl<T> PartialEq for PhantomInvariant<T> where T: ?Sized,

fn eq(&self, &Self) -> bool

impl<T> PartialOrd for PhantomInvariant<T> where T: ?Sized,

fn partial_cmp(&self, &Self) -> Option<Ordering>

impl<T> PrivateItems for PhantomInvariant<T> where T: ?Sized,

const VALUE: Self = _;

impl<T> TrivialClone for PhantomInvariant<T> where T: ?Sized,

impl<T> Variance for PhantomInvariant<T> where T: ?Sized,

Auto Trait Implementations

impl<T> Freeze for PhantomInvariant<T> where PhantomData<fn(T) -> T>: Freeze, T: ?Sized,

impl<T> RefUnwindSafe for PhantomInvariant<T> where PhantomData<fn(T) -> T>: RefUnwindSafe, T: ?Sized,

impl<T> Send for PhantomInvariant<T> where PhantomData<fn(T) -> T>: Send, T: ?Sized,

impl<T> Sync for PhantomInvariant<T> where PhantomData<fn(T) -> T>: Sync, T: ?Sized,

impl<T> Unpin for PhantomInvariant<T> where PhantomData<fn(T) -> T>: Unpin, T: ?Sized,

impl<T> UnsafeUnpin for PhantomInvariant<T> where PhantomData<fn(T) -> T>: UnsafeUnpin, T: ?Sized,

impl<T> UnwindSafe for PhantomInvariant<T> where PhantomData<fn(T) -> T>: UnwindSafe, T: ?Sized,

Blanket Implementations

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

fn type_id(&self) -> TypeId

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

fn borrow(&self) -> &T

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

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

impl<T> CloneToUninit for PhantomInvariant<T> where T: Clone,

unsafe fn clone_to_uninit(&self, dest: *mut u8)

impl<T> From<T> for PhantomInvariant<T>

fn from(t: T) -> T

Returns the argument unchanged.

impl<T> Printable for PhantomInvariant<T> where T: Copy + Debug,

impl<T> SizeHint for PhantomInvariant<T> where T: ?Sized,

fn lower_bound(&self) -> usize
fn upper_bound(&self) -> Option<usize>

impl<T> SizedTypeProperties for PhantomInvariant<T>

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

fn into(self) -> U

Calls U::from(self).

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

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

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

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

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