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<bool> for Option<()>

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§

Source§

impl<U: 'static + Equivalent<T>, T: 'static, Extra: 'static> Equivalent<Point<T, Extra>> for Point<U, Extra>

This implementation is the main goal of Equivalent: we assume transmuting the pointer is safe.