| 1 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::collectionsrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/::HashMaprust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/HashMap#; |
| 2 | |
| 3 | use ronrust-analyzer cargo ron 0.12.0 crate/::extensionsrust-analyzer cargo ron 0.12.0 extensions/::Extensionsrust-analyzer cargo ron 0.12.0 extensions/Extensions#; |
| 4 | use serderust-analyzer cargo serde 1.0.228 crate/::{Deserializerust-analyzer cargo serde_core 1.0.228 de/Deserialize#, Serializerust-analyzer cargo serde_core 1.0.228 ser/Serialize#}; |
| 5 | |
| 6 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:, Deserializerust-analyzer cargo serde_derive 1.0.228 Deserialize:, Serializerust-analyzer cargo serde_derive 1.0.228 Serialize:)] |
| 7 | struct UnitStructrust-analyzer cargo ron 0.12.0 UnitStruct#; |
| 8 | |
| 9 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:, Deserializerust-analyzer cargo serde_derive 1.0.228 Deserialize:, Serializerust-analyzer cargo serde_derive 1.0.228 Serialize:)] |
| 10 | struct NewTyperust-analyzer cargo ron 0.12.0 NewType#(f32); |
| 11 | |
| 12 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:, Deserializerust-analyzer cargo serde_derive 1.0.228 Deserialize:, Serializerust-analyzer cargo serde_derive 1.0.228 Serialize:)] |
| 13 | struct TupleStructrust-analyzer cargo ron 0.12.0 TupleStruct#(UnitStructrust-analyzer cargo ron 0.12.0 UnitStruct#, i8); |
| 14 | |
| 15 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:, Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq:, Hashrust-analyzer cargo core https://github.com/rust-lang/rust/library/core hash/macros/Hash:, Deserializerust-analyzer cargo serde_derive 1.0.228 Deserialize:, Serializerust-analyzer cargo serde_derive 1.0.228 Serialize:)] |
| 16 | struct Keyrust-analyzer cargo ron 0.12.0 Key#(u32); |
| 17 | |
| 18 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:, Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq:, Hashrust-analyzer cargo core https://github.com/rust-lang/rust/library/core hash/macros/Hash:, Deserializerust-analyzer cargo serde_derive 1.0.228 Deserialize:, Serializerust-analyzer cargo serde_derive 1.0.228 Serialize:)] |
| 19 | enum Enumrust-analyzer cargo ron 0.12.0 Enum# { |
| 20 | Unitrust-analyzer cargo ron 0.12.0 Enum#Unit#, |
| 21 | Boolrust-analyzer cargo ron 0.12.0 Enum#Bool#(bool), |
| 22 | Charsrust-analyzer cargo ron 0.12.0 Enum#Chars#(char, Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#), |
| 23 | } |
| 24 | |
| 25 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:, Deserializerust-analyzer cargo serde_derive 1.0.228 Deserialize:, Serializerust-analyzer cargo serde_derive 1.0.228 Serialize:)] |
| 26 | struct Structrust-analyzer cargo ron 0.12.0 Struct# { |
| 27 | tuplerust-analyzer cargo ron 0.12.0 Struct#tuple.: ((), NewTyperust-analyzer cargo ron 0.12.0 NewType#, TupleStructrust-analyzer cargo ron 0.12.0 TupleStruct#), |
| 28 | vecrust-analyzer cargo ron 0.12.0 Struct#vec.: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<UnitStructrust-analyzer cargo ron 0.12.0 UnitStruct#>>, |
| 29 | maprust-analyzer cargo ron 0.12.0 Struct#map.: HashMaprust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/HashMap#<Keyrust-analyzer cargo ron 0.12.0 Key#, Enumrust-analyzer cargo ron 0.12.0 Enum#>, |
| 30 | } |
| 31 | |
| 32 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 33 | fn roundtriprust-analyzer cargo ron 0.12.0 roundtrip().() { |
| 34 | let value = Structrust-analyzer cargo ron 0.12.0 Struct# { |
| 35 | tuplerust-analyzer cargo ron 0.12.0 Struct#tuple.: ((), NewTyperust-analyzer cargo ron 0.12.0 NewType#(0.5), TupleStructrust-analyzer cargo ron 0.12.0 TupleStruct#(UnitStructrust-analyzer cargo ron 0.12.0 UnitStruct#, -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i8][Neg]neg().5)), |
| 36 | vecrust-analyzer cargo ron 0.12.0 Struct#vec.: vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(UnitStructrust-analyzer cargo ron 0.12.0 UnitStruct#)], |
| 37 | maprust-analyzer cargo ron 0.12.0 Struct#map.: vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![ |
| 38 | (Keyrust-analyzer cargo ron 0.12.0 Key#(5), Enumrust-analyzer cargo ron 0.12.0 Enum#::Unitrust-analyzer cargo ron 0.12.0 Enum#Unit#), |
| 39 | (Keyrust-analyzer cargo ron 0.12.0 Key#(6), Enumrust-analyzer cargo ron 0.12.0 Enum#::Boolrust-analyzer cargo ron 0.12.0 Enum#Bool#(false)), |
| 40 | (Keyrust-analyzer cargo ron 0.12.0 Key#(7), Enumrust-analyzer cargo ron 0.12.0 Enum#::Boolrust-analyzer cargo ron 0.12.0 Enum#Bool#(true)), |
| 41 | (Keyrust-analyzer cargo ron 0.12.0 Key#(9), Enumrust-analyzer cargo ron 0.12.0 Enum#::Charsrust-analyzer cargo ron 0.12.0 Enum#Chars#('x', "".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().())), |
| 42 | ] |
| 43 | .into_iterrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][IntoIterator]into_iter().() |
| 44 | .collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().(), |
| 45 | }; |
| 46 | |
| 47 | let serial = ronrust-analyzer cargo ron 0.12.0 crate/::serrust-analyzer cargo ron 0.12.0 ser/::to_stringrust-analyzer cargo ron 0.12.0 ser/to_string().(&value).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 48 | |
| 49 | printlnrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/println!!("Serialized: {}", serial); |
| 50 | |
| 51 | let deserial = ronrust-analyzer cargo ron 0.12.0 crate/::derust-analyzer cargo ron 0.12.0 de/::from_strrust-analyzer cargo ron 0.12.0 de/from_str().(&serial); |
| 52 | |
| 53 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(value), deserial); |
| 54 | } |
| 55 | |
| 56 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 57 | fn roundtrip_prettyrust-analyzer cargo ron 0.12.0 roundtrip_pretty().() { |
| 58 | let value = Structrust-analyzer cargo ron 0.12.0 Struct# { |
| 59 | tuplerust-analyzer cargo ron 0.12.0 Struct#tuple.: ((), NewTyperust-analyzer cargo ron 0.12.0 NewType#(0.5), TupleStructrust-analyzer cargo ron 0.12.0 TupleStruct#(UnitStructrust-analyzer cargo ron 0.12.0 UnitStruct#, -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i8][Neg]neg().5)), |
| 60 | vecrust-analyzer cargo ron 0.12.0 Struct#vec.: vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(UnitStructrust-analyzer cargo ron 0.12.0 UnitStruct#)], |
| 61 | maprust-analyzer cargo ron 0.12.0 Struct#map.: vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![ |
| 62 | (Keyrust-analyzer cargo ron 0.12.0 Key#(5), Enumrust-analyzer cargo ron 0.12.0 Enum#::Unitrust-analyzer cargo ron 0.12.0 Enum#Unit#), |
| 63 | (Keyrust-analyzer cargo ron 0.12.0 Key#(6), Enumrust-analyzer cargo ron 0.12.0 Enum#::Boolrust-analyzer cargo ron 0.12.0 Enum#Bool#(false)), |
| 64 | (Keyrust-analyzer cargo ron 0.12.0 Key#(7), Enumrust-analyzer cargo ron 0.12.0 Enum#::Boolrust-analyzer cargo ron 0.12.0 Enum#Bool#(true)), |
| 65 | (Keyrust-analyzer cargo ron 0.12.0 Key#(9), Enumrust-analyzer cargo ron 0.12.0 Enum#::Charsrust-analyzer cargo ron 0.12.0 Enum#Chars#('x', "".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().())), |
| 66 | ] |
| 67 | .into_iterrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][IntoIterator]into_iter().() |
| 68 | .collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().(), |
| 69 | }; |
| 70 | |
| 71 | let pretty = ronrust-analyzer cargo ron 0.12.0 crate/::serrust-analyzer cargo ron 0.12.0 ser/::PrettyConfigrust-analyzer cargo ron 0.12.0 ser/PrettyConfig#::newrust-analyzer cargo ron 0.12.0 ser/impl#[PrettyConfig]new().() |
| 72 | .enumerate_arraysrust-analyzer cargo ron 0.12.0 ser/impl#[PrettyConfig]enumerate_arrays().(true) |
| 73 | .extensionsrust-analyzer cargo ron 0.12.0 ser/impl#[PrettyConfig]extensions().(Extensionsrust-analyzer cargo ron 0.12.0 extensions/Extensions#::IMPLICIT_SOMErust-analyzer cargo ron 0.12.0 extensions/impl#[Extensions]IMPLICIT_SOME.); |
| 74 | let serial = ronrust-analyzer cargo ron 0.12.0 crate/::serrust-analyzer cargo ron 0.12.0 ser/::to_string_prettyrust-analyzer cargo ron 0.12.0 ser/to_string_pretty().(&value, pretty).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 75 | |
| 76 | printlnrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/println!!("Serialized: {}", serial); |
| 77 | |
| 78 | let deserial = ronrust-analyzer cargo ron 0.12.0 crate/::derust-analyzer cargo ron 0.12.0 de/::from_strrust-analyzer cargo ron 0.12.0 de/from_str().(&serial); |
| 79 | |
| 80 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(value), deserial); |
| 81 | } |
| 82 | |
| 83 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 84 | fn roundtrip_sep_tuple_membersrust-analyzer cargo ron 0.12.0 roundtrip_sep_tuple_members().() { |
| 85 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, Deserializerust-analyzer cargo serde_derive 1.0.228 Deserialize:, PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:, Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq:, Serializerust-analyzer cargo serde_derive 1.0.228 Serialize:)] |
| 86 | pub enum FileOrMemrust-analyzer cargo ron 0.12.0 FileOrMem# { |
| 87 | Filerust-analyzer cargo ron 0.12.0 FileOrMem#File#(Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#), |
| 88 | Memoryrust-analyzer cargo ron 0.12.0 FileOrMem#Memory#, |
| 89 | } |
| 90 | |
| 91 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, Deserializerust-analyzer cargo serde_derive 1.0.228 Deserialize:, PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:, Serializerust-analyzer cargo serde_derive 1.0.228 Serialize:)] |
| 92 | struct Bothrust-analyzer cargo ron 0.12.0 Both# { |
| 93 | arust-analyzer cargo ron 0.12.0 Both#a.: Structrust-analyzer cargo ron 0.12.0 Struct#, |
| 94 | brust-analyzer cargo ron 0.12.0 Both#b.: FileOrMemrust-analyzer cargo ron 0.12.0 FileOrMem#, |
| 95 | } |
| 96 | |
| 97 | let a = Structrust-analyzer cargo ron 0.12.0 Struct# { |
| 98 | tuplerust-analyzer cargo ron 0.12.0 Struct#tuple.: ((), NewTyperust-analyzer cargo ron 0.12.0 NewType#(0.5), TupleStructrust-analyzer cargo ron 0.12.0 TupleStruct#(UnitStructrust-analyzer cargo ron 0.12.0 UnitStruct#, -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i8][Neg]neg().5)), |
| 99 | vecrust-analyzer cargo ron 0.12.0 Struct#vec.: vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(UnitStructrust-analyzer cargo ron 0.12.0 UnitStruct#)], |
| 100 | maprust-analyzer cargo ron 0.12.0 Struct#map.: vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![ |
| 101 | (Keyrust-analyzer cargo ron 0.12.0 Key#(5), Enumrust-analyzer cargo ron 0.12.0 Enum#::Unitrust-analyzer cargo ron 0.12.0 Enum#Unit#), |
| 102 | (Keyrust-analyzer cargo ron 0.12.0 Key#(6), Enumrust-analyzer cargo ron 0.12.0 Enum#::Boolrust-analyzer cargo ron 0.12.0 Enum#Bool#(false)), |
| 103 | (Keyrust-analyzer cargo ron 0.12.0 Key#(7), Enumrust-analyzer cargo ron 0.12.0 Enum#::Boolrust-analyzer cargo ron 0.12.0 Enum#Bool#(true)), |
| 104 | (Keyrust-analyzer cargo ron 0.12.0 Key#(9), Enumrust-analyzer cargo ron 0.12.0 Enum#::Charsrust-analyzer cargo ron 0.12.0 Enum#Chars#('x', "".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().())), |
| 105 | ] |
| 106 | .into_iterrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][IntoIterator]into_iter().() |
| 107 | .collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().(), |
| 108 | }; |
| 109 | let b = FileOrMemrust-analyzer cargo ron 0.12.0 FileOrMem#::Filerust-analyzer cargo ron 0.12.0 FileOrMem#File#("foo".to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str][ToOwned]to_owned().()); |
| 110 | |
| 111 | let value = Bothrust-analyzer cargo ron 0.12.0 Both# { arust-analyzer cargo ron 0.12.0 Both#a., brust-analyzer cargo ron 0.12.0 Both#b. }; |
| 112 | |
| 113 | let pretty = ronrust-analyzer cargo ron 0.12.0 crate/::serrust-analyzer cargo ron 0.12.0 ser/::PrettyConfigrust-analyzer cargo ron 0.12.0 ser/PrettyConfig#::newrust-analyzer cargo ron 0.12.0 ser/impl#[PrettyConfig]new().().separate_tuple_membersrust-analyzer cargo ron 0.12.0 ser/impl#[PrettyConfig]separate_tuple_members().(true); |
| 114 | let serial = ronrust-analyzer cargo ron 0.12.0 crate/::serrust-analyzer cargo ron 0.12.0 ser/::to_string_prettyrust-analyzer cargo ron 0.12.0 ser/to_string_pretty().(&value, pretty).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 115 | |
| 116 | printlnrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/println!!("Serialized: {}", serial); |
| 117 | |
| 118 | let deserial = ronrust-analyzer cargo ron 0.12.0 crate/::derust-analyzer cargo ron 0.12.0 de/::from_strrust-analyzer cargo ron 0.12.0 de/from_str().(&serial); |
| 119 | |
| 120 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(value), deserial); |
| 121 | } |