| 1 | use ronrust-analyzer cargo ron 0.12.0 crate/::{ |
| 2 | serrust-analyzer cargo ron 0.12.0 ser/::{to_string_prettyrust-analyzer cargo ron 0.12.0 ser/to_string_pretty()., PrettyConfigrust-analyzer cargo ron 0.12.0 ser/PrettyConfig#}, |
| 3 | to_stringrust-analyzer cargo ron 0.12.0 ser/to_string()., |
| 4 | }; |
| 5 | 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#}; |
| 6 | |
| 7 | #[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:)] |
| 8 | struct Pointrust-analyzer cargo ron 0.12.0 Point# { |
| 9 | xrust-analyzer cargo ron 0.12.0 Point#x.: f64, |
| 10 | yrust-analyzer cargo ron 0.12.0 Point#y.: f64, |
| 11 | } |
| 12 | |
| 13 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 14 | fn test_struct_namesrust-analyzer cargo ron 0.12.0 test_struct_names().() { |
| 15 | let value = Pointrust-analyzer cargo ron 0.12.0 Point# { xrust-analyzer cargo ron 0.12.0 Point#x.: 1.0, yrust-analyzer cargo ron 0.12.0 Point#y.: 2.0 }; |
| 16 | let struct_name = to_string_prettyrust-analyzer cargo ron 0.12.0 ser/to_string_pretty().(&value, PrettyConfigrust-analyzer cargo ron 0.12.0 ser/PrettyConfig#::defaultrust-analyzer cargo ron 0.12.0 ser/impl#[PrettyConfig][Default]default().().struct_namesrust-analyzer cargo ron 0.12.0 ser/impl#[PrettyConfig]struct_names().(true)); |
| 17 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 18 | struct_name, |
| 19 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#("Point(\n x: 1.0,\n y: 2.0,\n)".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()) |
| 20 | ); |
| 21 | let no_struct_name = to_stringrust-analyzer cargo ron 0.12.0 ser/to_string().(&value); |
| 22 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(no_struct_name, Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#("(x:1.0,y:2.0)".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().())); |
| 23 | } |