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
use struct_convert::Convert;
#[derive(Debug, PartialEq)]
struct B {
num: String,
name: String,
}
#[derive(Debug, Convert, PartialEq)]
#[convert(into = "B")]
struct A {
#[convert_field(ignore)]
id: i64,
#[convert_field(to_string)]
num: i64,
#[convert_field(unwrap)]
name: Option<String>,
}
fn main() {
}
#[test]
fn test_ignore() {
let a = A {
id: 2,
num: 1,
name: Some("Jack".to_string()),
};
let b: B = a.into();
debug_assert_eq!(
B {
num: "1".to_string(),
name: "Jack".to_string(),
},
b
);
}