In a comment, author of the question mentioned 'avoiding fastidious hand mapping' as part of their question. Rust crate o2o (which I am the author of) tries to deal specifically with this problem:
struct Person { name: String, age: u8, } #[derive(o2o)] #[o2o(from_owned(Person))] struct PersonDto { name: String, #[o2o(as_type(u8))] age: u64, }
This will generate following code automatically:
impl std::convert::From<Person> for PersonDto { fn from(value: Person) -> PersonDto { PersonDto { name: value.name, age: value.age as u64, } } }
It can generate implementations for From, Into and custom IntoExisting traits for structs, tuple structs, tuples, and can handle cases like mismatching field names, types, skipping fields, nested structs, nested collections, 'uneven' structs, wrapping structs etc. It is also designed to be applicable on any side of the mapping.
mapstructunnecessary.