| 1 | 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#, serrust-analyzer cargo ron 0.12.0 ser/::PrettyConfigrust-analyzer cargo ron 0.12.0 ser/PrettyConfig#, Optionsrust-analyzer cargo ron 0.12.0 options/Options#}; |
| 2 | 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#}; |
| 3 | |
| 4 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Serializerust-analyzer cargo serde_derive 1.0.228 Serialize:, Deserializerust-analyzer cargo serde_derive 1.0.228 Deserialize:)] |
| 5 | struct Newtyperust-analyzer cargo ron 0.12.0 Newtype#(f64); |
| 6 | |
| 7 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Serializerust-analyzer cargo serde_derive 1.0.228 Serialize:, Deserializerust-analyzer cargo serde_derive 1.0.228 Deserialize:)] |
| 8 | struct Structrust-analyzer cargo ron 0.12.0 Struct#(Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<u32>, Newtyperust-analyzer cargo ron 0.12.0 Newtype#); |
| 9 | |
| 10 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 11 | fn default_optionsrust-analyzer cargo ron 0.12.0 default_options().() { |
| 12 | let ron = Optionsrust-analyzer cargo ron 0.12.0 options/Options#::defaultrust-analyzer cargo ron 0.12.0 options/impl#[Options][Default]default().(); |
| 13 | |
| 14 | let de: Structrust-analyzer cargo ron 0.12.0 Struct# = ron.from_strrust-analyzer cargo ron 0.12.0 options/impl#[Options]from_str().("(Some(42),(4.2))").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 15 | let ser = ron.to_stringrust-analyzer cargo ron 0.12.0 options/impl#[Options]to_string().(&de).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 16 | |
| 17 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(ser, "(Some(42),(4.2))"); |
| 18 | } |
| 19 | |
| 20 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 21 | fn without_any_optionsrust-analyzer cargo ron 0.12.0 without_any_options().() { |
| 22 | let mut ron = Optionsrust-analyzer cargo ron 0.12.0 options/Options#::defaultrust-analyzer cargo ron 0.12.0 options/impl#[Options][Default]default().().with_default_extensionrust-analyzer cargo ron 0.12.0 options/impl#[Options]with_default_extension().(Extensionsrust-analyzer cargo ron 0.12.0 extensions/Extensions#::allrust-analyzer cargo ron 0.12.0 extensions/impl#[Extensions]all().()); |
| 23 | for extension in Extensionsrust-analyzer cargo ron 0.12.0 extensions/Extensions#::allrust-analyzer cargo ron 0.12.0 extensions/impl#[Extensions]all().().iterrust-analyzer cargo ron 0.12.0 extensions/impl#[Extensions]iter().() { |
| 24 | ron = ron.without_default_extensionrust-analyzer cargo ron 0.12.0 options/impl#[Options]without_default_extension().(extension); |
| 25 | } |
| 26 | |
| 27 | let de: Structrust-analyzer cargo ron 0.12.0 Struct# = ron.from_strrust-analyzer cargo ron 0.12.0 options/impl#[Options]from_str().("(Some(42),(4.2))").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 28 | let ser = ron.to_stringrust-analyzer cargo ron 0.12.0 options/impl#[Options]to_string().(&de).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 29 | |
| 30 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(ser, "(Some(42),(4.2))"); |
| 31 | } |
| 32 | |
| 33 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 34 | fn single_default_extensionrust-analyzer cargo ron 0.12.0 single_default_extension().() { |
| 35 | let ron = Optionsrust-analyzer cargo ron 0.12.0 options/Options#::defaultrust-analyzer cargo ron 0.12.0 options/impl#[Options][Default]default().().with_default_extensionrust-analyzer cargo ron 0.12.0 options/impl#[Options]with_default_extension().(Extensionsrust-analyzer cargo ron 0.12.0 extensions/Extensions#::IMPLICIT_SOMErust-analyzer cargo ron 0.12.0 extensions/impl#[Extensions]IMPLICIT_SOME.); |
| 36 | |
| 37 | let de: Structrust-analyzer cargo ron 0.12.0 Struct# = ron.from_strrust-analyzer cargo ron 0.12.0 options/impl#[Options]from_str().("(42,(4.2))").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 38 | let ser = ron.to_stringrust-analyzer cargo ron 0.12.0 options/impl#[Options]to_string().(&de).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 39 | |
| 40 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(ser, "(42,(4.2))"); |
| 41 | |
| 42 | let de: Structrust-analyzer cargo ron 0.12.0 Struct# = ron.from_strrust-analyzer cargo ron 0.12.0 options/impl#[Options]from_str().("#)").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 43 | let ser = ron.to_stringrust-analyzer cargo ron 0.12.0 options/impl#[Options]to_string().(&de).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 44 | |
| 45 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(ser, "(42,(4.2))"); |
| 46 | |
| 47 | let de: Structrust-analyzer cargo ron 0.12.0 Struct# = ron |
| 48 | .from_strrust-analyzer cargo ron 0.12.0 options/impl#[Options]from_str().("#![enable(implicit_some)]#") |
| 49 | .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 50 | let ser = ron.to_stringrust-analyzer cargo ron 0.12.0 options/impl#[Options]to_string().(&de).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 51 | |
| 52 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(ser, "(42,(4.2))"); |
| 53 | |
| 54 | let de: Structrust-analyzer cargo ron 0.12.0 Struct# = ron |
| 55 | .from_strrust-analyzer cargo ron 0.12.0 options/impl#[Options]from_str().("#![enable(implicit_some)]#") |
| 56 | .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 57 | let ser = ron |
| 58 | .to_string_prettyrust-analyzer cargo ron 0.12.0 options/impl#[Options]to_string_pretty().( |
| 59 | &de, |
| 60 | 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().(Extensionsrust-analyzer cargo ron 0.12.0 extensions/Extensions#::UNWRAP_NEWTYPESrust-analyzer cargo ron 0.12.0 extensions/impl#[Extensions]UNWRAP_NEWTYPES.), |
| 61 | ) |
| 62 | .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 63 | |
| 64 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(ser, "#![enable(unwrap_newtypes)]\n(42, 4.2)"); |
| 65 | } |
| 66 | |
| 67 | #[cfg(feature = "std")] |
| 68 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 69 | fn reader_io_errorrust-analyzer cargo ron 0.12.0 reader_io_error().() { |
| 70 | struct Readerrust-analyzer cargo ron 0.12.0 Reader#<'a> { |
| 71 | bufrust-analyzer cargo ron 0.12.0 Reader#buf.: &'a [u8], |
| 72 | } |
| 73 | |
| 74 | impl<'a> stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Readrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Read# for Readerrust-analyzer cargo ron 0.12.0 Reader#<'a> { |
| 75 | fn readrust-analyzer cargo ron 0.12.0 impl#[`Reader<'a>`][Read]read().(&mut self, buf: &mut [u8]) -> stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Resultrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Result#<usize> { |
| 76 | let written = self.bufrust-analyzer cargo ron 0.12.0 Reader#buf..readrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/impls/impl#[`&[u8]`][Read]read().(buf)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 77 | if written rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().0 { |
| 78 | Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Errorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Error#::newrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/impl#[Error]new().(stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::ErrorKindrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/ErrorKind#::BrokenPiperust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/ErrorKind#BrokenPipe#, "oh no")) |
| 79 | } else { |
| 80 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(written) |
| 81 | } |
| 82 | } |
| 83 | } |
| 84 | |
| 85 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 86 | ronrust-analyzer cargo ron 0.12.0 crate/::derust-analyzer cargo ron 0.12.0 de/::from_readerrust-analyzer cargo ron 0.12.0 de/from_reader().::<Readerrust-analyzer cargo ron 0.12.0 Reader#, ()>(Readerrust-analyzer cargo ron 0.12.0 Reader# { bufrust-analyzer cargo ron 0.12.0 Reader#buf.: b"" }).unwrap_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap_err().(), |
| 87 | ronrust-analyzer cargo ron 0.12.0 crate/::errorrust-analyzer cargo ron 0.12.0 error/::SpannedErrorrust-analyzer cargo ron 0.12.0 error/SpannedError# { |
| 88 | coderust-analyzer cargo ron 0.12.0 error/SpannedError#code.: ronrust-analyzer cargo ron 0.12.0 crate/::Errorrust-analyzer cargo ron 0.12.0 error/Error#::Iorust-analyzer cargo ron 0.12.0 error/Error#Io#(Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#::fromrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`From<&str>`]from().("oh no")), |
| 89 | spanrust-analyzer cargo ron 0.12.0 error/SpannedError#span.: ronrust-analyzer cargo ron 0.12.0 crate/::errorrust-analyzer cargo ron 0.12.0 error/::Spanrust-analyzer cargo ron 0.12.0 error/Span# { |
| 90 | startrust-analyzer cargo ron 0.12.0 error/Span#start.: ronrust-analyzer cargo ron 0.12.0 crate/::errorrust-analyzer cargo ron 0.12.0 error/::Positionrust-analyzer cargo ron 0.12.0 error/Position# { linerust-analyzer cargo ron 0.12.0 error/Position#line.: 1, colrust-analyzer cargo ron 0.12.0 error/Position#col.: 1 }, |
| 91 | endrust-analyzer cargo ron 0.12.0 error/Span#end.: ronrust-analyzer cargo ron 0.12.0 crate/::errorrust-analyzer cargo ron 0.12.0 error/::Positionrust-analyzer cargo ron 0.12.0 error/Position# { linerust-analyzer cargo ron 0.12.0 error/Position#line.: 1, colrust-analyzer cargo ron 0.12.0 error/Position#col.: 1 }, |
| 92 | } |
| 93 | } |
| 94 | ); |
| 95 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 96 | ronrust-analyzer cargo ron 0.12.0 crate/::derust-analyzer cargo ron 0.12.0 de/::from_readerrust-analyzer cargo ron 0.12.0 de/from_reader().::<Readerrust-analyzer cargo ron 0.12.0 Reader#, ()>(Readerrust-analyzer cargo ron 0.12.0 Reader# { bufrust-analyzer cargo ron 0.12.0 Reader#buf.: b"hello" }).unwrap_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap_err().(), |
| 97 | ronrust-analyzer cargo ron 0.12.0 crate/::errorrust-analyzer cargo ron 0.12.0 error/::SpannedErrorrust-analyzer cargo ron 0.12.0 error/SpannedError# { |
| 98 | coderust-analyzer cargo ron 0.12.0 error/SpannedError#code.: ronrust-analyzer cargo ron 0.12.0 crate/::Errorrust-analyzer cargo ron 0.12.0 error/Error#::Iorust-analyzer cargo ron 0.12.0 error/Error#Io#(Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#::fromrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`From<&str>`]from().("oh no")), |
| 99 | spanrust-analyzer cargo ron 0.12.0 error/SpannedError#span.: ronrust-analyzer cargo ron 0.12.0 crate/::errorrust-analyzer cargo ron 0.12.0 error/::Spanrust-analyzer cargo ron 0.12.0 error/Span# { |
| 100 | startrust-analyzer cargo ron 0.12.0 error/Span#start.: ronrust-analyzer cargo ron 0.12.0 crate/::errorrust-analyzer cargo ron 0.12.0 error/::Positionrust-analyzer cargo ron 0.12.0 error/Position# { linerust-analyzer cargo ron 0.12.0 error/Position#line.: 1, colrust-analyzer cargo ron 0.12.0 error/Position#col.: 1 }, |
| 101 | endrust-analyzer cargo ron 0.12.0 error/Span#end.: ronrust-analyzer cargo ron 0.12.0 crate/::errorrust-analyzer cargo ron 0.12.0 error/::Positionrust-analyzer cargo ron 0.12.0 error/Position# { linerust-analyzer cargo ron 0.12.0 error/Position#line.: 1, colrust-analyzer cargo ron 0.12.0 error/Position#col.: 6 }, |
| 102 | } |
| 103 | } |
| 104 | ); |
| 105 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 106 | ronrust-analyzer cargo ron 0.12.0 crate/::derust-analyzer cargo ron 0.12.0 de/::from_readerrust-analyzer cargo ron 0.12.0 de/from_reader().::<Readerrust-analyzer cargo ron 0.12.0 Reader#, ()>(Readerrust-analyzer cargo ron 0.12.0 Reader# { |
| 107 | bufrust-analyzer cargo ron 0.12.0 Reader#buf.: b"hello\nmy \xff" |
| 108 | }) |
| 109 | .unwrap_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap_err().(), |
| 110 | ronrust-analyzer cargo ron 0.12.0 crate/::errorrust-analyzer cargo ron 0.12.0 error/::SpannedErrorrust-analyzer cargo ron 0.12.0 error/SpannedError# { |
| 111 | coderust-analyzer cargo ron 0.12.0 error/SpannedError#code.: ronrust-analyzer cargo ron 0.12.0 crate/::Errorrust-analyzer cargo ron 0.12.0 error/Error#::Iorust-analyzer cargo ron 0.12.0 error/Error#Io#(Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#::fromrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`From<&str>`]from().("oh no")), |
| 112 | spanrust-analyzer cargo ron 0.12.0 error/SpannedError#span.: ronrust-analyzer cargo ron 0.12.0 crate/::errorrust-analyzer cargo ron 0.12.0 error/::Spanrust-analyzer cargo ron 0.12.0 error/Span# { |
| 113 | startrust-analyzer cargo ron 0.12.0 error/Span#start.: ronrust-analyzer cargo ron 0.12.0 crate/::errorrust-analyzer cargo ron 0.12.0 error/::Positionrust-analyzer cargo ron 0.12.0 error/Position# { linerust-analyzer cargo ron 0.12.0 error/Position#line.: 1, colrust-analyzer cargo ron 0.12.0 error/Position#col.: 1 }, |
| 114 | endrust-analyzer cargo ron 0.12.0 error/Span#end.: ronrust-analyzer cargo ron 0.12.0 crate/::errorrust-analyzer cargo ron 0.12.0 error/::Positionrust-analyzer cargo ron 0.12.0 error/Position# { linerust-analyzer cargo ron 0.12.0 error/Position#line.: 2, colrust-analyzer cargo ron 0.12.0 error/Position#col.: 4 }, |
| 115 | } |
| 116 | } |
| 117 | ); |
| 118 | } |