Module frunk_core::generic
source · Expand description
This module holds the machinery behind Generic
.
It contains the Generic
trait and some helper methods for using the
Generic
trait without having to use universal function call syntax.
§Examples
use frunk::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 = frunk::convert_from(a_person); // done
Traits§
- A trait that converts from a type to a generic representation.
Functions§
- Converts one type
Src
into another typeDst
assuming they have the same representation typeRepr
. - Given a generic representation
Repr
of aDst
, returnsDst
. - Given a value of type
Src
, returns its generic representationRepr
. - Maps a value of a given type
Origin
using a function on a typeInter
which has the same representation type ofOrigin
. - Maps a value of a given type
Origin
using a function on the representation typeRepr
ofOrigin
.