Equivalent

Trait Equivalent 

Source
pub trait Equivalent<T>: Sized {
    // Required methods
    fn into_equivalent(self) -> T;
    fn from_equivalent(object: T) -> Self;
}
Expand description

Implemented if both types have the exact same layout. This implies having the same MaybeHasNiche::MnArray.

This is represented as two-way conversion for two reasons:

  • to highlight that the conversion is actual equivalence
  • to increase flexibility (mostly to go around the orphan rule)

Required Methods§

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl Equivalent<<i8 as HasOtherSign>::OtherSign> for i8

Source§

fn into_equivalent(self) -> <i8 as HasOtherSign>::OtherSign

Source§

fn from_equivalent(object: <i8 as HasOtherSign>::OtherSign) -> Self

Source§

impl Equivalent<<u8 as HasOtherSign>::OtherSign> for u8

Source§

fn into_equivalent(self) -> <u8 as HasOtherSign>::OtherSign

Source§

fn from_equivalent(object: <u8 as HasOtherSign>::OtherSign) -> Self

Source§

impl Equivalent<bool> for Option<()>

Source§

impl Equivalent<i8> for Option<NonZero<i8>>

Source§

fn into_equivalent(self) -> i8

Source§

fn from_equivalent(object: i8) -> Self

Source§

impl Equivalent<u8> for Option<NonZero<u8>>

Source§

fn into_equivalent(self) -> u8

Source§

fn from_equivalent(object: u8) -> Self

Source§

impl Equivalent<NonZero<<i8 as HasOtherSign>::OtherSign>> for NonZero<i8>

Source§

fn into_equivalent(self) -> NonZero<<i8 as HasOtherSign>::OtherSign>

Source§

fn from_equivalent(object: NonZero<<i8 as HasOtherSign>::OtherSign>) -> Self

Source§

impl Equivalent<NonZero<<u8 as HasOtherSign>::OtherSign>> for NonZero<u8>

Source§

fn into_equivalent(self) -> NonZero<<u8 as HasOtherSign>::OtherSign>

Source§

fn from_equivalent(object: NonZero<<u8 as HasOtherSign>::OtherSign>) -> Self

Source§

impl<'a, B: 'a + ToOwned + ?Sized> Equivalent<<B as ToOwned>::Owned> for Cow<'a, B>

Source§

fn into_equivalent(self) -> B::Owned

Source§

fn from_equivalent(object: B::Owned) -> Self

Source§

impl<K: Ord> Equivalent<BTreeMap<K, ()>> for BTreeSet<K>

Source§

fn into_equivalent(self) -> BTreeMap<K, ()>

Source§

fn from_equivalent(object: BTreeMap<K, ()>) -> Self

Source§

impl<T> Equivalent<T> for (T,)

Source§

fn into_equivalent(self) -> T

Source§

fn from_equivalent(object: T) -> Self

Source§

impl<T> Equivalent<T> for Box<T>

Source§

fn into_equivalent(self) -> T

Source§

fn from_equivalent(object: T) -> Self

Source§

impl<T, U: Equivalent<T>> Equivalent<Option<T>> for Option<U>

Source§

fn into_equivalent(self) -> Option<T>

Source§

fn from_equivalent(option: Option<T>) -> Self

Source§

impl<T: Clone> Equivalent<T> for Arc<T>

Source§

fn into_equivalent(self) -> T

Source§

fn from_equivalent(object: T) -> Self

Implementors§