Skip to main content

GenericRepr

Trait GenericRepr 

Source
pub trait GenericRepr: Sized {
    type Repr;

    // Required methods
    fn into_repr(self) -> Self::Repr;
    fn from_repr(repr: Self::Repr) -> Self;
}
Expand description

Convert between a concrete type and its generic representation.

§Laws

  1. Round-trip: T::from_repr(t.into_repr()) == t
  2. Inverse: T::into_repr(T::from_repr(r)) == r

Required Associated Types§

Source

type Repr

The generic representation type (built from Sum/Product/Unit/Void).

Required Methods§

Source

fn into_repr(self) -> Self::Repr

Convert this value to its generic representation.

Source

fn from_repr(repr: Self::Repr) -> Self

Reconstruct a value from its generic representation.

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 GenericRepr for bool

Source§

type Repr = Sum<Unit, Unit>

Source§

fn into_repr(self) -> Self::Repr

Source§

fn from_repr(repr: Self::Repr) -> Self

Source§

impl GenericRepr for ()

Source§

impl<A, B> GenericRepr for (A, B)

Source§

type Repr = Product<A, Product<B, Unit>>

Source§

fn into_repr(self) -> Self::Repr

Source§

fn from_repr(repr: Self::Repr) -> Self

Source§

impl<A, B, C> GenericRepr for (A, B, C)

Source§

type Repr = Product<A, Product<B, Product<C, Unit>>>

Source§

fn into_repr(self) -> Self::Repr

Source§

fn from_repr(repr: Self::Repr) -> Self

Source§

impl<T> GenericRepr for Option<T>

Source§

type Repr = Sum<T, Unit>

Source§

fn into_repr(self) -> Self::Repr

Source§

fn from_repr(repr: Self::Repr) -> Self

Source§

impl<T, E> GenericRepr for Result<T, E>

Source§

type Repr = Sum<T, E>

Source§

fn into_repr(self) -> Self::Repr

Source§

fn from_repr(repr: Self::Repr) -> Self

Implementors§