Trait frunk_core::generic::Generic
[−]
[src]
pub trait Generic { type Repr; fn into(self) -> Self::Repr; fn from(r: Self::Repr) -> Self; fn convert_from<A>(a: A) -> Self
where
A: Generic<Repr = Self::Repr>,
Self: Sized, { ... } }
A trait that converts from a type to a generic representation
For the most part, you should be using the derivation that is available through frunk_derive to generate instances of this typeclass for your types.
Examples
use frunk_core::hlist::*; use frunk_core::generic::*; #[derive(Generic)] struct ApiPerson<'a> { FirstName: &'a str, LastName: &'a str, Age: usize, } #[derive(Generic)] struct DomainPerson<'a> { first_name: &'a str, last_name: &'a str, age: usize, } let a_person = ApiPerson { FirstName: "Joe", LastName: "Blow", Age: 30, }; let d_person: DomainPerson = convert_from(a_person); // doneRun
Associated Types
type Repr
The generic representation type
Required Methods
fn into(self) -> Self::Repr
Go from something to Repr
fn from(r: Self::Repr) -> Self
Go from Repr to something
Provided Methods
fn convert_from<A>(a: A) -> Self where
A: Generic<Repr = Self::Repr>,
Self: Sized,
A: Generic<Repr = Self::Repr>,
Self: Sized,
From one type to another using a type with a compatible generic representation
Implementations on Foreign Types
impl Generic for ()
[src]
impl<T0> Generic for (T0,)
[src]
impl<T1, T0> Generic for (T1, T0)
[src]
impl<T2, T1, T0> Generic for (T2, T1, T0)
[src]
impl<T3, T2, T1, T0> Generic for (T3, T2, T1, T0)
[src]
impl<T4, T3, T2, T1, T0> Generic for (T4, T3, T2, T1, T0)
[src]
impl<T5, T4, T3, T2, T1, T0> Generic for (T5, T4, T3, T2, T1, T0)
[src]
impl<T6, T5, T4, T3, T2, T1, T0> Generic for (T6, T5, T4, T3, T2, T1, T0)
[src]
impl<T7, T6, T5, T4, T3, T2, T1, T0> Generic for (T7, T6, T5, T4, T3, T2, T1, T0)
[src]
impl<T8, T7, T6, T5, T4, T3, T2, T1, T0> Generic for (T8, T7, T6, T5, T4, T3, T2, T1, T0)
[src]
impl<T9, T8, T7, T6, T5, T4, T3, T2, T1, T0> Generic for (T9, T8, T7, T6, T5, T4, T3, T2, T1, T0)
[src]
impl<T10, T9, T8, T7, T6, T5, T4, T3, T2, T1, T0> Generic for (T10, T9, T8, T7, T6, T5, T4, T3, T2, T1, T0)
[src]
impl<T11, T10, T9, T8, T7, T6, T5, T4, T3, T2, T1, T0> Generic for (T11, T10, T9, T8, T7, T6, T5, T4, T3, T2, T1, T0)
[src]
type Repr = HCons<T11, HCons<T10, HCons<T9, HCons<T8, HCons<T7, HCons<T6, HCons<T5, HCons<T4, HCons<T3, HCons<T2, HCons<T1, HCons<T0, HNil>>>>>>>>>>>>
fn into(self) -> Self::Repr
[src]
fn from(r: Self::Repr) -> Self
[src]
fn convert_from<A>(a: A) -> Self where
A: Generic<Repr = Self::Repr>,
Self: Sized,
[src]
A: Generic<Repr = Self::Repr>,
Self: Sized,
impl<T12, T11, T10, T9, T8, T7, T6, T5, T4, T3, T2, T1, T0> Generic for (T12, T11, T10, T9, T8, T7, T6, T5, T4, T3, T2, T1, T0)
[src]
type Repr = HCons<T12, HCons<T11, HCons<T10, HCons<T9, HCons<T8, HCons<T7, HCons<T6, HCons<T5, HCons<T4, HCons<T3, HCons<T2, HCons<T1, HCons<T0, HNil>>>>>>>>>>>>>
fn into(self) -> Self::Repr
[src]
fn from(r: Self::Repr) -> Self
[src]
fn convert_from<A>(a: A) -> Self where
A: Generic<Repr = Self::Repr>,
Self: Sized,
[src]
A: Generic<Repr = Self::Repr>,
Self: Sized,
impl<T13, T12, T11, T10, T9, T8, T7, T6, T5, T4, T3, T2, T1, T0> Generic for (T13, T12, T11, T10, T9, T8, T7, T6, T5, T4, T3, T2, T1, T0)
[src]
type Repr = HCons<T13, HCons<T12, HCons<T11, HCons<T10, HCons<T9, HCons<T8, HCons<T7, HCons<T6, HCons<T5, HCons<T4, HCons<T3, HCons<T2, HCons<T1, HCons<T0, HNil>>>>>>>>>>>>>>
fn into(self) -> Self::Repr
[src]
fn from(r: Self::Repr) -> Self
[src]
fn convert_from<A>(a: A) -> Self where
A: Generic<Repr = Self::Repr>,
Self: Sized,
[src]
A: Generic<Repr = Self::Repr>,
Self: Sized,
impl<T14, T13, T12, T11, T10, T9, T8, T7, T6, T5, T4, T3, T2, T1, T0> Generic for (T14, T13, T12, T11, T10, T9, T8, T7, T6, T5, T4, T3, T2, T1, T0)
[src]
type Repr = HCons<T14, HCons<T13, HCons<T12, HCons<T11, HCons<T10, HCons<T9, HCons<T8, HCons<T7, HCons<T6, HCons<T5, HCons<T4, HCons<T3, HCons<T2, HCons<T1, HCons<T0, HNil>>>>>>>>>>>>>>>
fn into(self) -> Self::Repr
[src]
fn from(r: Self::Repr) -> Self
[src]
fn convert_from<A>(a: A) -> Self where
A: Generic<Repr = Self::Repr>,
Self: Sized,
[src]
A: Generic<Repr = Self::Repr>,
Self: Sized,
impl<T15, T14, T13, T12, T11, T10, T9, T8, T7, T6, T5, T4, T3, T2, T1, T0> Generic for (T15, T14, T13, T12, T11, T10, T9, T8, T7, T6, T5, T4, T3, T2, T1, T0)
[src]
type Repr = HCons<T15, HCons<T14, HCons<T13, HCons<T12, HCons<T11, HCons<T10, HCons<T9, HCons<T8, HCons<T7, HCons<T6, HCons<T5, HCons<T4, HCons<T3, HCons<T2, HCons<T1, HCons<T0, HNil>>>>>>>>>>>>>>>>
fn into(self) -> Self::Repr
[src]
fn from(r: Self::Repr) -> Self
[src]
fn convert_from<A>(a: A) -> Self where
A: Generic<Repr = Self::Repr>,
Self: Sized,
[src]
A: Generic<Repr = Self::Repr>,
Self: Sized,
impl<T16, T15, T14, T13, T12, T11, T10, T9, T8, T7, T6, T5, T4, T3, T2, T1, T0> Generic for (T16, T15, T14, T13, T12, T11, T10, T9, T8, T7, T6, T5, T4, T3, T2, T1, T0)
[src]
type Repr = HCons<T16, HCons<T15, HCons<T14, HCons<T13, HCons<T12, HCons<T11, HCons<T10, HCons<T9, HCons<T8, HCons<T7, HCons<T6, HCons<T5, HCons<T4, HCons<T3, HCons<T2, HCons<T1, HCons<T0, HNil>>>>>>>>>>>>>>>>>
fn into(self) -> Self::Repr
[src]
fn from(r: Self::Repr) -> Self
[src]
fn convert_from<A>(a: A) -> Self where
A: Generic<Repr = Self::Repr>,
Self: Sized,
[src]
A: Generic<Repr = Self::Repr>,
Self: Sized,
impl<T17, T16, T15, T14, T13, T12, T11, T10, T9, T8, T7, T6, T5, T4, T3, T2, T1, T0> Generic for (T17, T16, T15, T14, T13, T12, T11, T10, T9, T8, T7, T6, T5, T4, T3, T2, T1, T0)
[src]
type Repr = HCons<T17, HCons<T16, HCons<T15, HCons<T14, HCons<T13, HCons<T12, HCons<T11, HCons<T10, HCons<T9, HCons<T8, HCons<T7, HCons<T6, HCons<T5, HCons<T4, HCons<T3, HCons<T2, HCons<T1, HCons<T0, HNil>>>>>>>>>>>>>>>>>>
fn into(self) -> Self::Repr
[src]
fn from(r: Self::Repr) -> Self
[src]
fn convert_from<A>(a: A) -> Self where
A: Generic<Repr = Self::Repr>,
Self: Sized,
[src]
A: Generic<Repr = Self::Repr>,
Self: Sized,
impl<T18, T17, T16, T15, T14, T13, T12, T11, T10, T9, T8, T7, T6, T5, T4, T3, T2, T1, T0> Generic for (T18, T17, T16, T15, T14, T13, T12, T11, T10, T9, T8, T7, T6, T5, T4, T3, T2, T1, T0)
[src]
type Repr = HCons<T18, HCons<T17, HCons<T16, HCons<T15, HCons<T14, HCons<T13, HCons<T12, HCons<T11, HCons<T10, HCons<T9, HCons<T8, HCons<T7, HCons<T6, HCons<T5, HCons<T4, HCons<T3, HCons<T2, HCons<T1, HCons<T0, HNil>>>>>>>>>>>>>>>>>>>
fn into(self) -> Self::Repr
[src]
fn from(r: Self::Repr) -> Self
[src]
fn convert_from<A>(a: A) -> Self where
A: Generic<Repr = Self::Repr>,
Self: Sized,
[src]
A: Generic<Repr = Self::Repr>,
Self: Sized,
impl<T19, T18, T17, T16, T15, T14, T13, T12, T11, T10, T9, T8, T7, T6, T5, T4, T3, T2, T1, T0> Generic for (T19, T18, T17, T16, T15, T14, T13, T12, T11, T10, T9, T8, T7, T6, T5, T4, T3, T2, T1, T0)
[src]
type Repr = HCons<T19, HCons<T18, HCons<T17, HCons<T16, HCons<T15, HCons<T14, HCons<T13, HCons<T12, HCons<T11, HCons<T10, HCons<T9, HCons<T8, HCons<T7, HCons<T6, HCons<T5, HCons<T4, HCons<T3, HCons<T2, HCons<T1, HCons<T0, HNil>>>>>>>>>>>>>>>>>>>>
fn into(self) -> Self::Repr
[src]
fn from(r: Self::Repr) -> Self
[src]
fn convert_from<A>(a: A) -> Self where
A: Generic<Repr = Self::Repr>,
Self: Sized,
[src]
A: Generic<Repr = Self::Repr>,
Self: Sized,
impl<T20, T19, T18, T17, T16, T15, T14, T13, T12, T11, T10, T9, T8, T7, T6, T5, T4, T3, T2, T1, T0> Generic for (T20, T19, T18, T17, T16, T15, T14, T13, T12, T11, T10, T9, T8, T7, T6, T5, T4, T3, T2, T1, T0)
[src]
type Repr = HCons<T20, HCons<T19, HCons<T18, HCons<T17, HCons<T16, HCons<T15, HCons<T14, HCons<T13, HCons<T12, HCons<T11, HCons<T10, HCons<T9, HCons<T8, HCons<T7, HCons<T6, HCons<T5, HCons<T4, HCons<T3, HCons<T2, HCons<T1, HCons<T0, HNil>>>>>>>>>>>>>>>>>>>>>
fn into(self) -> Self::Repr
[src]
fn from(r: Self::Repr) -> Self
[src]
fn convert_from<A>(a: A) -> Self where
A: Generic<Repr = Self::Repr>,
Self: Sized,
[src]
A: Generic<Repr = Self::Repr>,
Self: Sized,
impl<T21, T20, T19, T18, T17, T16, T15, T14, T13, T12, T11, T10, T9, T8, T7, T6, T5, T4, T3, T2, T1, T0> Generic for (T21, T20, T19, T18, T17, T16, T15, T14, T13, T12, T11, T10, T9, T8, T7, T6, T5, T4, T3, T2, T1, T0)
[src]
type Repr = HCons<T21, HCons<T20, HCons<T19, HCons<T18, HCons<T17, HCons<T16, HCons<T15, HCons<T14, HCons<T13, HCons<T12, HCons<T11, HCons<T10, HCons<T9, HCons<T8, HCons<T7, HCons<T6, HCons<T5, HCons<T4, HCons<T3, HCons<T2, HCons<T1, HCons<T0, HNil>>>>>>>>>>>>>>>>>>>>>>
fn into(self) -> Self::Repr
[src]
fn from(r: Self::Repr) -> Self
[src]
fn convert_from<A>(a: A) -> Self where
A: Generic<Repr = Self::Repr>,
Self: Sized,
[src]
A: Generic<Repr = Self::Repr>,
Self: Sized,
impl<T22, T21, T20, T19, T18, T17, T16, T15, T14, T13, T12, T11, T10, T9, T8, T7, T6, T5, T4, T3, T2, T1, T0> Generic for (T22, T21, T20, T19, T18, T17, T16, T15, T14, T13, T12, T11, T10, T9, T8, T7, T6, T5, T4, T3, T2, T1, T0)
[src]
type Repr = HCons<T22, HCons<T21, HCons<T20, HCons<T19, HCons<T18, HCons<T17, HCons<T16, HCons<T15, HCons<T14, HCons<T13, HCons<T12, HCons<T11, HCons<T10, HCons<T9, HCons<T8, HCons<T7, HCons<T6, HCons<T5, HCons<T4, HCons<T3, HCons<T2, HCons<T1, HCons<T0, HNil>>>>>>>>>>>>>>>>>>>>>>>
fn into(self) -> Self::Repr
[src]
fn from(r: Self::Repr) -> Self
[src]
fn convert_from<A>(a: A) -> Self where
A: Generic<Repr = Self::Repr>,
Self: Sized,
[src]
A: Generic<Repr = Self::Repr>,
Self: Sized,
impl<T23, T22, T21, T20, T19, T18, T17, T16, T15, T14, T13, T12, T11, T10, T9, T8, T7, T6, T5, T4, T3, T2, T1, T0> Generic for (T23, T22, T21, T20, T19, T18, T17, T16, T15, T14, T13, T12, T11, T10, T9, T8, T7, T6, T5, T4, T3, T2, T1, T0)
[src]
type Repr = HCons<T23, HCons<T22, HCons<T21, HCons<T20, HCons<T19, HCons<T18, HCons<T17, HCons<T16, HCons<T15, HCons<T14, HCons<T13, HCons<T12, HCons<T11, HCons<T10, HCons<T9, HCons<T8, HCons<T7, HCons<T6, HCons<T5, HCons<T4, HCons<T3, HCons<T2, HCons<T1, HCons<T0, HNil>>>>>>>>>>>>>>>>>>>>>>>>
fn into(self) -> Self::Repr
[src]
fn from(r: Self::Repr) -> Self
[src]
fn convert_from<A>(a: A) -> Self where
A: Generic<Repr = Self::Repr>,
Self: Sized,
[src]
A: Generic<Repr = Self::Repr>,
Self: Sized,