| 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/::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:(Serializerust-analyzer cargo serde_derive 1.0.228 Serialize:)] |
| 6 | struct Configrust-analyzer cargo ron 0.12.0 Config# { |
| 7 | floatrust-analyzer cargo ron 0.12.0 Config#float.: (f32, f64), |
| 8 | tuplerust-analyzer cargo ron 0.12.0 Config#tuple.: TupleStructrust-analyzer cargo ron 0.12.0 TupleStruct#, |
| 9 | maprust-analyzer cargo ron 0.12.0 Config#map.: HashMaprust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/HashMap#<u8, char>, |
| 10 | nestedrust-analyzer cargo ron 0.12.0 Config#nested.: Nestedrust-analyzer cargo ron 0.12.0 Nested#, |
| 11 | varrust-analyzer cargo ron 0.12.0 Config#var.: Variantrust-analyzer cargo ron 0.12.0 Variant#, |
| 12 | arrayrust-analyzer cargo ron 0.12.0 Config#array.: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<()>, |
| 13 | } |
| 14 | |
| 15 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Serializerust-analyzer cargo serde_derive 1.0.228 Serialize:)] |
| 16 | struct TupleStructrust-analyzer cargo ron 0.12.0 TupleStruct#((), bool); |
| 17 | |
| 18 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Serializerust-analyzer cargo serde_derive 1.0.228 Serialize:)] |
| 19 | enum Variantrust-analyzer cargo ron 0.12.0 Variant# { |
| 20 | Arust-analyzer cargo ron 0.12.0 Variant#A#(u8, &'static str), |
| 21 | } |
| 22 | |
| 23 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Serializerust-analyzer cargo serde_derive 1.0.228 Serialize:)] |
| 24 | struct Nestedrust-analyzer cargo ron 0.12.0 Nested# { |
| 25 | arust-analyzer cargo ron 0.12.0 Nested#a.: Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#, |
| 26 | brust-analyzer cargo ron 0.12.0 Nested#b.: char, |
| 27 | } |
| 28 | |
| 29 | const EXPECTEDrust-analyzer cargo ron 0.12.0 EXPECTED.: &str = "( |
| 30 | float: (2.18, -1.1), |
| 31 | tuple: ((), false), |
| 32 | map: {8: '1'}, |
| 33 | nested: (a: \"a\", b: 'b'), |
| 34 | var: A(255, \"\"), |
| 35 | array: [(), (), ()], |
| 36 | )"; |
| 37 | |
| 38 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 39 | fn depth_limitrust-analyzer cargo ron 0.12.0 depth_limit().() { |
| 40 | let data = Configrust-analyzer cargo ron 0.12.0 Config# { |
| 41 | floatrust-analyzer cargo ron 0.12.0 Config#float.: (2.18, -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][Neg]neg().1.1), |
| 42 | tuplerust-analyzer cargo ron 0.12.0 Config#tuple.: TupleStructrust-analyzer cargo ron 0.12.0 TupleStruct#((), false), |
| 43 | maprust-analyzer cargo ron 0.12.0 Config#map.: vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![(8, '1')].into_iterrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][IntoIterator]into_iter().().collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().(), |
| 44 | nestedrust-analyzer cargo ron 0.12.0 Config#nested.: Nestedrust-analyzer cargo ron 0.12.0 Nested# { |
| 45 | arust-analyzer cargo ron 0.12.0 Nested#a.: "a".to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str][ToOwned]to_owned().(), |
| 46 | brust-analyzer cargo ron 0.12.0 Nested#b.: 'b', |
| 47 | }, |
| 48 | varrust-analyzer cargo ron 0.12.0 Config#var.: Variantrust-analyzer cargo ron 0.12.0 Variant#::Arust-analyzer cargo ron 0.12.0 Variant#A#(!rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u8][Not]not().0, ""), |
| 49 | arrayrust-analyzer cargo ron 0.12.0 Config#array.: vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![(); 3], |
| 50 | }; |
| 51 | |
| 52 | 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().() |
| 53 | .depth_limitrust-analyzer cargo ron 0.12.0 ser/impl#[PrettyConfig]depth_limit().(1) |
| 54 | .separate_tuple_membersrust-analyzer cargo ron 0.12.0 ser/impl#[PrettyConfig]separate_tuple_members().(true) |
| 55 | .enumerate_arraysrust-analyzer cargo ron 0.12.0 ser/impl#[PrettyConfig]enumerate_arrays().(true) |
| 56 | .new_linerust-analyzer cargo ron 0.12.0 ser/impl#[PrettyConfig]new_line().("\n"); |
| 57 | 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().(&data, pretty); |
| 58 | |
| 59 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(s, Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(EXPECTEDrust-analyzer cargo ron 0.12.0 EXPECTED..to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().())); |
| 60 | } |