Module frunk_core::generic [] [src]

This module holds the machinery behind Generic.

It contains the Generic typeclass and some helper methods for using the Generic type class without having to use universal function call syntax.

Examples

#[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

Traits

Generic

A trait that converts from a type to a generic representation

Functions

convert_from

Converts one type into another assuming they have the same generic Representation

from_generic

Given a generic Representation of an A, returns A

into_generic

Given an A, returns its generic Representation