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§
Sourcefn into_equivalent(self) -> T
fn into_equivalent(self) -> T
Inverse of Equivalent::from_equivalent.
Sourcefn from_equivalent(object: T) -> Self
fn from_equivalent(object: T) -> Self
Inverse of Equivalent::into_equivalent.
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<()>
impl Equivalent<bool> for Option<()>
fn into_equivalent(self) -> bool
fn from_equivalent(object: bool) -> Self
Source§impl<K: Ord> Equivalent<BTreeMap<K, ()>> for BTreeSet<K>
impl<K: Ord> Equivalent<BTreeMap<K, ()>> for BTreeSet<K>
fn into_equivalent(self) -> BTreeMap<K, ()>
fn from_equivalent(object: BTreeMap<K, ()>) -> Self
Source§impl<T> Equivalent<T> for (T,)
impl<T> Equivalent<T> for (T,)
fn into_equivalent(self) -> T
fn from_equivalent(object: T) -> Self
Source§impl<T> Equivalent<T> for Box<T>
impl<T> Equivalent<T> for Box<T>
fn into_equivalent(self) -> T
fn from_equivalent(object: T) -> Self
Source§impl<T, U: Equivalent<T>> Equivalent<Option<T>> for Option<U>
impl<T, U: Equivalent<T>> Equivalent<Option<T>> for Option<U>
fn into_equivalent(self) -> Option<T>
fn from_equivalent(option: Option<T>) -> Self
Source§impl<T: Clone> Equivalent<T> for Arc<T>
impl<T: Clone> Equivalent<T> for Arc<T>
fn into_equivalent(self) -> T
fn from_equivalent(object: T) -> Self
Implementors§
impl<U: 'static + Equivalent<T>, T: 'static> Equivalent<Point<T>> for Point<U>
This implementation is the main goal of Equivalent: we assume transmuting the pointer is
safe.