mapstruct/
lib.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
pub use mapstruct_derive::MapStruct;

#[cfg(test)]
mod test {
    use super::*;

    #[derive(MapStruct)]
    #[mapstruct(
        #[derive(Debug)]
        struct Y<
            +'a,
        > {
            ~id -> pub id,
            ~name: &'a str,
            ~some: &'a str,
            +last_name: &'a str,
            -height,
        }
    )]
    struct X {
        id: i64,
        name: String,
        age: i32,
        height: f32,
        some: String,
    }

    impl<'a> Into<Y<'a>> for &'a X {
        fn into(self) -> Y<'a> {
            Y {
                id: self.id,
                name: &*self.name,
                age: self.age,
                some: &*self.some,
                last_name: &*self.name,
            }
        }
    }

    #[test]
    fn test() {
        println!("Hello, world!")
    }
}