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); // doneTraits§
- Generic
- A trait that converts from a type to a generic representation.
Functions§
- convert_
from - Converts one type
Srcinto another typeDstassuming they have the same representation typeRepr. - from_
generic - Given a generic representation
Reprof aDst, returnsDst. - into_
generic - Given a value of type
Src, returns its generic representationRepr. - map_
inter - Maps a value of a given type
Originusing a function on a typeInterwhich has the same representation type ofOrigin. - map_
repr - Maps a value of a given type
Originusing a function on the representation typeReprofOrigin.