![github] ![crates-io] ![docs-rs]
This library provides a convenient derive macro for implementing [mapper_api::Mapper
```rust use mapper::Mapper;
fn mapaccountid(accountid: &u16) -> String{ accountid.to_string() }
struct User{ #[to(Person, field=name)] pub name: String, #[to(Person, with=mapaccountid)] pub accountid: u16, pub age: u8 } struct Person{ pub name: String, pub accountid: String, pub age: u8 } ```
Default behavior is to take each field of annotated struct and clone those fields in the destination struct initializer : ```rust
struct User{
pub name: String
}
struct Person{
pub name: String
}
Generate 🔄 :
rust
impl Mapper
#[to(Animal, Vehicle)]
#[to(<DestinationType>, field=<destination_field>, with=<transformation_function>)]
This parameter is mandatory and have to be present in the To struct attribute
Optional parameter, target the destination type field
Optional parameter, provide a function to transform the annotated field to the destination field
License: MIT OR Apache-2.0