[simple] main_type = "Simple" definition = """ #[derive(PartialEq, Debug, Serialize)] pub struct Simple { pub integer: i32, pub character: char, pub float: f32, pub string: String, pub boolean: bool, } """ value = """ Simple { integer: 123, character: 'c', float: std::f32::consts::PI, string: "text string".into(), boolean: false } """ [nested] main_type = "Nested" support_types = "Inner" definition = """ #[derive(PartialEq, Debug, Serialize)] pub struct Nested { pub inner: Inner, } #[derive(PartialEq, Debug, Serialize)] pub struct Inner { pub value: i32, } """ value = """ Nested { inner: Inner { value: 123 } } """ [recursive] main_type = "Recursive" definition = """ #[derive(PartialEq, Debug, Serialize)] pub struct Recursive { pub inner: Option>, } """ value = """ Recursive { inner: Some(Box::new(Recursive { inner: None })) } """ name_mappings.Recursive = "&Recursive" test_values.inner = "Some(&Recursive { inner: None })" [complex] main_type = "Complex" definition = """ #[derive(Debug, Serialize)] pub struct Complex { pub tuple: (i32, f32, String), pub vector: Vec, pub byte_arr: Vec, pub map: std::collections::HashMap, } """ value = """ { let mut map = std::collections::HashMap::new(); map.insert("0".into(), "test".into()); map.insert("120".into(), "test longer".into()); map.insert("\\"".into(), "test escaping".into()); Complex { tuple: (1, 1.0, "tuple entry".into()), vector: vec![1, 2, 3, 4, 5, -1, -2, -3, -4, -5], byte_arr: b"asdfghj".to_vec(), map } } """ test_values.tuple = "(1, 1.0, \"tuple entry\".into())" test_values.vector = "vec![1, 2, 3, 4, 5, -1, -2, -3, -4, -5]" test_values.byte_arr = "b\"asdfghj\".to_vec()" test_values."map[\"0\"]" = "\"test\"" test_values."map[\"120\"]" = "\"test longer\"" test_values."map[\"\\\"\"]" = "\"test escaping\"" [floats] main_type = "Floats" definition = """ #[derive(PartialEq, Debug, Serialize)] pub struct Floats(pub Vec); """ value = """ Floats(vec![ 123456789e30, 123456789e-30, 12345.6789 ]) """ [enums] main_type = "Container" support_types = "Enum,Unit" definition = """ #[derive(PartialEq, Debug, Serialize)] pub struct Unit; #[derive(PartialEq, Debug, Serialize)] pub enum Enum { Empty, Unit(Unit), Tuple(i32, String), Struct{ key: i32, value: String }, EmptyTuple(), EmptyStruct {}, } #[derive(PartialEq, Debug, Serialize)] pub struct Container(pub Vec); """ value = """ { Container(vec![ Enum::Unit(Unit), Enum::Tuple(1, "test".into()), Enum::Struct{ key: 1, value: "test".into() }, Enum::EmptyTuple(), Enum::EmptyStruct{}, // this is intentionally last, to catch an error at previous step Enum::Empty, ]) } """ test_values = { 0 = """&[ Enum::Unit(Unit), Enum::Tuple(1, "test".into()), Enum::Struct{ key: 1, value: "test".into() }, Enum::EmptyTuple(), Enum::EmptyStruct{}, // this is intentionally last, to catch an error at previous step Enum::Empty, ]""" } [slice] main_type = "Container" definition = """ #[derive(PartialEq, Debug, Serialize)] pub struct Container(pub Vec); """ value = """ Container(vec![1, 2]) """ [tuple] main_type = "Container" definition = """ #[derive(PartialEq, Debug, Serialize)] pub struct Container(pub (u8, u8)); """ value = """ Container((1, 2)) """ [unit] main_type = "ZeroSizeContainer" definition = """ #[derive(PartialEq, Debug, Serialize)] pub struct ZeroSizeContainer(pub ()); """ value = """ ZeroSizeContainer(()) """ [empty_fields_issue_3] main_type = "Foo" support_types = "UnitType,UnitStruct,UnitTuple" definition = """ #[derive(PartialEq, Debug, Serialize)] pub struct UnitType; #[derive(PartialEq, Debug, Serialize)] pub struct UnitStruct {} #[derive(PartialEq, Debug, Serialize)] pub struct UnitTuple(); #[derive(Debug, Serialize)] pub struct Foo { pub vec: Vec, pub map: std::collections::HashMap, pub unit: (), pub unit_type: UnitType, pub unit_struct: UnitStruct, pub unit_tuple: UnitTuple, pub last: String } """ value = """ { Foo { vec: vec![], map: std::collections::HashMap::new(), unit: (), unit_type: UnitType, unit_struct: UnitStruct {}, unit_tuple: UnitTuple(), last: "".into() } } """ test_values.vec = "std::vec::Vec::<&str>::new()" test_values."map.len()" = "0" test_values.unit = "()" test_values.unit_type = "UnitType" test_values.unit_struct = "UnitStruct {}" test_values.unit_tuple = "UnitTuple()" test_values.last = "\"\"" [escapist_strings_issue_4] main_type = "Foo" definition = """ #[derive(PartialEq, Debug, Serialize)] pub struct Foo { pub s: Vec, pub c: Vec, } """ value = """ Foo { s: vec!["\\"".into(), "\\n".into(), "'".into(), "❤".into()], c: vec!['\\'', '\\n', '"', '❤'], } """ test_values = { s = "[\"\\\"\", \"\\n\", \"'\", \"❤\"]", c = "['\\'', '\\n', '\"', '❤']" }