| 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 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#}; |
| 4 | |
| 5 | #[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:)] |
| 6 | struct UnitStructrust-analyzer cargo ron 0.12.0 UnitStruct#; |
| 7 | |
| 8 | #[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:)] |
| 9 | struct NewTyperust-analyzer cargo ron 0.12.0 NewType#(f32); |
| 10 | |
| 11 | #[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:)] |
| 12 | struct TupleStructrust-analyzer cargo ron 0.12.0 TupleStruct#(UnitStructrust-analyzer cargo ron 0.12.0 UnitStruct#, i8); |
| 13 | |
| 14 | #[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:)] |
| 15 | struct Keyrust-analyzer cargo ron 0.12.0 Key#(u32); |
| 16 | |
| 17 | #[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:)] |
| 18 | enum Enumrust-analyzer cargo ron 0.12.0 Enum# { |
| 19 | Unitrust-analyzer cargo ron 0.12.0 Enum#Unit#, |
| 20 | Boolrust-analyzer cargo ron 0.12.0 Enum#Bool#(bool), |
| 21 | Charsrust-analyzer cargo ron 0.12.0 Enum#Chars#(char, Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#), |
| 22 | } |
| 23 | |
| 24 | #[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:)] |
| 25 | struct Structrust-analyzer cargo ron 0.12.0 Struct# { |
| 26 | 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#), |
| 27 | 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#>>, |
| 28 | 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#>, |
| 29 | } |
| 30 | |
| 31 | const CONFIG_U_NTrust-analyzer cargo ron 0.12.0 CONFIG_U_NT.: &str = " |
| 32 | #![enable(unwrap_newtypes)] |
| 33 | |
| 34 | ( |
| 35 | tuple: ((), 0.5, ((), -5)), |
| 36 | vec: [ |
| 37 | None, |
| 38 | Some(()), |
| 39 | ], |
| 40 | map: { |
| 41 | 7: Bool(true), |
| 42 | 9: Chars('x', \"\"), |
| 43 | 6: Bool(false), |
| 44 | 5: Unit, |
| 45 | }, |
| 46 | ) |
| 47 | "; |
| 48 | |
| 49 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 50 | fn unwrap_newtypesrust-analyzer cargo ron 0.12.0 unwrap_newtypes().() { |
| 51 | let d: Structrust-analyzer cargo ron 0.12.0 Struct# = 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().(CONFIG_U_NTrust-analyzer cargo ron 0.12.0 CONFIG_U_NT.).expectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]expect().("Failed to deserialize"); |
| 52 | |
| 53 | printlnrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/println!!("unwrap_newtypes: {:#?}", d); |
| 54 | |
| 55 | let s = 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().( |
| 56 | &d, |
| 57 | 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#::defaultrust-analyzer cargo ron 0.12.0 ser/impl#[PrettyConfig][Default]default().().extensionsrust-analyzer cargo ron 0.12.0 ser/impl#[PrettyConfig]extensions().(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#::UNWRAP_NEWTYPESrust-analyzer cargo ron 0.12.0 extensions/impl#[Extensions]UNWRAP_NEWTYPES.), |
| 58 | ) |
| 59 | .expectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]expect().("Failed to serialize"); |
| 60 | |
| 61 | let d2: Structrust-analyzer cargo ron 0.12.0 Struct# = 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().(&s).expectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]expect().("Failed to deserialize"); |
| 62 | |
| 63 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(d, d2); |
| 64 | } |
| 65 | |
| 66 | const CONFIG_I_Srust-analyzer cargo ron 0.12.0 CONFIG_I_S.: &str = " |
| 67 | #![enable(implicit_some)] |
| 68 | |
| 69 | ( |
| 70 | tuple: ((), (0.5), ((), -5)), |
| 71 | vec: [ |
| 72 | None, |
| 73 | (), |
| 74 | UnitStruct, |
| 75 | None, |
| 76 | (), |
| 77 | ], |
| 78 | map: { |
| 79 | (7): Bool(true), |
| 80 | (9): Chars('x', \"\"), |
| 81 | (6): Bool(false), |
| 82 | (5): Unit, |
| 83 | }, |
| 84 | ) |
| 85 | "; |
| 86 | |
| 87 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 88 | fn implicit_somerust-analyzer cargo ron 0.12.0 implicit_some().() { |
| 89 | let d: Structrust-analyzer cargo ron 0.12.0 Struct# = 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().(CONFIG_I_Srust-analyzer cargo ron 0.12.0 CONFIG_I_S.).expectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]expect().("Failed to deserialize"); |
| 90 | |
| 91 | printlnrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/println!!("implicit_some: {:#?}", d); |
| 92 | } |