| 1 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::f64rust-analyzer cargo std https://github.com/rust-lang/rust/library/std f64/; |
| 2 | |
| 3 | use ronrust-analyzer cargo ron 0.12.0 crate/::{ |
| 4 | errorrust-analyzer cargo ron 0.12.0 error/::Errorrust-analyzer cargo ron 0.12.0 error/Error#, |
| 5 | valuerust-analyzer cargo ron 0.12.0 value/::{Maprust-analyzer cargo ron 0.12.0 value/map/Map#, Numberrust-analyzer cargo ron 0.12.0 value/number/Number#, Valuerust-analyzer cargo ron 0.12.0 value/Value#}, |
| 6 | }; |
| 7 | use serde_deriverust-analyzer cargo serde_derive 1.0.228 crate/::{Deserializerust-analyzer cargo serde_derive 1.0.228 Deserialize:, Serializerust-analyzer cargo serde_derive 1.0.228 Serialize:}; |
| 8 | |
| 9 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 10 | fn boolrust-analyzer cargo ron 0.12.0 bool().() { |
| 11 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!("true".parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().(), Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Valuerust-analyzer cargo ron 0.12.0 value/Value#::Boolrust-analyzer cargo ron 0.12.0 value/Value#Bool#(true))); |
| 12 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!("false".parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().(), Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Valuerust-analyzer cargo ron 0.12.0 value/Value#::Boolrust-analyzer cargo ron 0.12.0 value/Value#Bool#(false))); |
| 13 | |
| 14 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(ronrust-analyzer cargo ron 0.12.0 crate/::to_stringrust-analyzer cargo ron 0.12.0 ser/to_string().(&Valuerust-analyzer cargo ron 0.12.0 value/Value#::Boolrust-analyzer cargo ron 0.12.0 value/Value#Bool#(true)).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(), "true"); |
| 15 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(ronrust-analyzer cargo ron 0.12.0 crate/::to_stringrust-analyzer cargo ron 0.12.0 ser/to_string().(&Valuerust-analyzer cargo ron 0.12.0 value/Value#::Boolrust-analyzer cargo ron 0.12.0 value/Value#Bool#(false)).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(), "false"); |
| 16 | } |
| 17 | |
| 18 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 19 | fn charrust-analyzer cargo ron 0.12.0 char().() { |
| 20 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!("'a'".parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().(), Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Valuerust-analyzer cargo ron 0.12.0 value/Value#::Charrust-analyzer cargo ron 0.12.0 value/Value#Char#('a'))); |
| 21 | |
| 22 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(ronrust-analyzer cargo ron 0.12.0 crate/::to_stringrust-analyzer cargo ron 0.12.0 ser/to_string().(&Valuerust-analyzer cargo ron 0.12.0 value/Value#::Charrust-analyzer cargo ron 0.12.0 value/Value#Char#('a')).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(), "'a'"); |
| 23 | } |
| 24 | |
| 25 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 26 | fn maprust-analyzer cargo ron 0.12.0 map().() { |
| 27 | let mut map = Maprust-analyzer cargo ron 0.12.0 value/map/Map#::newrust-analyzer cargo ron 0.12.0 value/map/impl#[Map]new().(); |
| 28 | map.insertrust-analyzer cargo ron 0.12.0 value/map/impl#[Map]insert().(Valuerust-analyzer cargo ron 0.12.0 value/Value#::Charrust-analyzer cargo ron 0.12.0 value/Value#Char#('a'), Valuerust-analyzer cargo ron 0.12.0 value/Value#::Numberrust-analyzer cargo ron 0.12.0 value/Value#Number#(Numberrust-analyzer cargo ron 0.12.0 value/number/Number#::U8rust-analyzer cargo ron 0.12.0 value/number/Number#U8#(1))); |
| 29 | map.insertrust-analyzer cargo ron 0.12.0 value/map/impl#[Map]insert().(Valuerust-analyzer cargo ron 0.12.0 value/Value#::Charrust-analyzer cargo ron 0.12.0 value/Value#Char#('b'), Valuerust-analyzer cargo ron 0.12.0 value/Value#::Numberrust-analyzer cargo ron 0.12.0 value/Value#Number#(Numberrust-analyzer cargo ron 0.12.0 value/number/Number#::newrust-analyzer cargo ron 0.12.0 value/number/impl#[Number]new().(2f32))); |
| 30 | let map = Valuerust-analyzer cargo ron 0.12.0 value/Value#::Maprust-analyzer cargo ron 0.12.0 value/Value#Map#(map); |
| 31 | |
| 32 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(ronrust-analyzer cargo ron 0.12.0 crate/::to_stringrust-analyzer cargo ron 0.12.0 ser/to_string().(&map).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(), "{'a':1,'b':2.0}"); |
| 33 | |
| 34 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!("{ 'a': 1, 'b': 2.0 }".parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().(), Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(map)); |
| 35 | } |
| 36 | |
| 37 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 38 | fn numberrust-analyzer cargo ron 0.12.0 number().() { |
| 39 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!("42".parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().(), Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Valuerust-analyzer cargo ron 0.12.0 value/Value#::Numberrust-analyzer cargo ron 0.12.0 value/Value#Number#(Numberrust-analyzer cargo ron 0.12.0 value/number/Number#::U8rust-analyzer cargo ron 0.12.0 value/number/Number#U8#(42)))); |
| 40 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 41 | "3.141592653589793".parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().(), |
| 42 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Valuerust-analyzer cargo ron 0.12.0 value/Value#::Numberrust-analyzer cargo ron 0.12.0 value/Value#Number#(Numberrust-analyzer cargo ron 0.12.0 value/number/Number#::newrust-analyzer cargo ron 0.12.0 value/number/impl#[Number]new().(f64rust-analyzer cargo std https://github.com/rust-lang/rust/library/std f64/::constsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core f64/consts/::PIrust-analyzer cargo core https://github.com/rust-lang/rust/library/core f64/consts/PI.))) |
| 43 | ); |
| 44 | |
| 45 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 46 | ronrust-analyzer cargo ron 0.12.0 crate/::to_stringrust-analyzer cargo ron 0.12.0 ser/to_string().(&Valuerust-analyzer cargo ron 0.12.0 value/Value#::Numberrust-analyzer cargo ron 0.12.0 value/Value#Number#(Numberrust-analyzer cargo ron 0.12.0 value/number/Number#::U8rust-analyzer cargo ron 0.12.0 value/number/Number#U8#(42))).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(), |
| 47 | "42" |
| 48 | ); |
| 49 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 50 | ronrust-analyzer cargo ron 0.12.0 crate/::to_stringrust-analyzer cargo ron 0.12.0 ser/to_string().(&Valuerust-analyzer cargo ron 0.12.0 value/Value#::Numberrust-analyzer cargo ron 0.12.0 value/Value#Number#(Numberrust-analyzer cargo ron 0.12.0 value/number/Number#::F64rust-analyzer cargo ron 0.12.0 value/number/Number#F64#(f64rust-analyzer cargo std https://github.com/rust-lang/rust/library/std f64/::constsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core f64/consts/::PIrust-analyzer cargo core https://github.com/rust-lang/rust/library/core f64/consts/PI..intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()))).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(), |
| 51 | "3.141592653589793" |
| 52 | ); |
| 53 | } |
| 54 | |
| 55 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 56 | fn optionrust-analyzer cargo ron 0.12.0 option().() { |
| 57 | let opt = Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/impl#[`Box<T>`]new().(Valuerust-analyzer cargo ron 0.12.0 value/Value#::Charrust-analyzer cargo ron 0.12.0 value/Value#Char#('c'))); |
| 58 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!("Some('c')".parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().(), Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Valuerust-analyzer cargo ron 0.12.0 value/Value#::Optionrust-analyzer cargo ron 0.12.0 value/Value#Option#(opt))); |
| 59 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!("None".parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().(), Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Valuerust-analyzer cargo ron 0.12.0 value/Value#::Optionrust-analyzer cargo ron 0.12.0 value/Value#Option#(Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#))); |
| 60 | |
| 61 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 62 | ronrust-analyzer cargo ron 0.12.0 crate/::to_stringrust-analyzer cargo ron 0.12.0 ser/to_string().(&Valuerust-analyzer cargo ron 0.12.0 value/Value#::Optionrust-analyzer cargo ron 0.12.0 value/Value#Option#(Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/impl#[`Box<T>`]new().(Valuerust-analyzer cargo ron 0.12.0 value/Value#::Charrust-analyzer cargo ron 0.12.0 value/Value#Char#('c'))))).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(), |
| 63 | "Some('c')" |
| 64 | ); |
| 65 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(ronrust-analyzer cargo ron 0.12.0 crate/::to_stringrust-analyzer cargo ron 0.12.0 ser/to_string().(&Valuerust-analyzer cargo ron 0.12.0 value/Value#::Optionrust-analyzer cargo ron 0.12.0 value/Value#Option#(Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#)).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(), "None"); |
| 66 | } |
| 67 | |
| 68 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 69 | fn stringrust-analyzer cargo ron 0.12.0 string().() { |
| 70 | let normal = "\"String\""; |
| 71 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(normal.parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().(), Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Valuerust-analyzer cargo ron 0.12.0 value/Value#::Stringrust-analyzer cargo ron 0.12.0 value/Value#String#("String".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()))); |
| 72 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 73 | ronrust-analyzer cargo ron 0.12.0 crate/::to_stringrust-analyzer cargo ron 0.12.0 ser/to_string().(&Valuerust-analyzer cargo ron 0.12.0 value/Value#::Stringrust-analyzer cargo ron 0.12.0 value/Value#String#("String".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().())).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(), |
| 74 | "\"String\"" |
| 75 | ); |
| 76 | |
| 77 | let raw = "r\"Raw String\""; |
| 78 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(raw.parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().(), Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Valuerust-analyzer cargo ron 0.12.0 value/Value#::Stringrust-analyzer cargo ron 0.12.0 value/Value#String#("Raw String".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()))); |
| 79 | |
| 80 | let raw_hashes = "r#\"Raw String\"#"; |
| 81 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(raw_hashes.parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().(), Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Valuerust-analyzer cargo ron 0.12.0 value/Value#::Stringrust-analyzer cargo ron 0.12.0 value/Value#String#("Raw String".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()))); |
| 82 | |
| 83 | let raw_escaped = "r##\"Contains \"#\"##"; |
| 84 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 85 | raw_escaped.parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().(), |
| 86 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Valuerust-analyzer cargo ron 0.12.0 value/Value#::Stringrust-analyzer cargo ron 0.12.0 value/Value#String#("Contains \"#".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().())) |
| 87 | ); |
| 88 | |
| 89 | let raw_multi_line = "r\"Multi\nLine\""; |
| 90 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 91 | raw_multi_line.parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().(), |
| 92 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Valuerust-analyzer cargo ron 0.12.0 value/Value#::Stringrust-analyzer cargo ron 0.12.0 value/Value#String#("Multi\nLine".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().())) |
| 93 | ); |
| 94 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 95 | ronrust-analyzer cargo ron 0.12.0 crate/::to_stringrust-analyzer cargo ron 0.12.0 ser/to_string().(&Valuerust-analyzer cargo ron 0.12.0 value/Value#::Stringrust-analyzer cargo ron 0.12.0 value/Value#String#("Multi\nLine".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().())).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(), |
| 96 | "\"Multi\\nLine\"" |
| 97 | ); |
| 98 | } |
| 99 | |
| 100 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 101 | fn byte_stringrust-analyzer cargo ron 0.12.0 byte_string().() { |
| 102 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 103 | "b\"\\x01\\u{2}\\0\\x04\"".parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().(), |
| 104 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Valuerust-analyzer cargo ron 0.12.0 value/Value#::Bytesrust-analyzer cargo ron 0.12.0 value/Value#Bytes#(vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![1, 2, 0, 4])) |
| 105 | ); |
| 106 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 107 | ronrust-analyzer cargo ron 0.12.0 crate/::to_stringrust-analyzer cargo ron 0.12.0 ser/to_string().(&Valuerust-analyzer cargo ron 0.12.0 value/Value#::Bytesrust-analyzer cargo ron 0.12.0 value/Value#Bytes#(vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![1, 2, 0, 4])).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(), |
| 108 | "b\"\\x01\\x02\\x00\\x04\"" |
| 109 | ); |
| 110 | } |
| 111 | |
| 112 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 113 | fn seqrust-analyzer cargo ron 0.12.0 seq().() { |
| 114 | let seq = Valuerust-analyzer cargo ron 0.12.0 value/Value#::Seqrust-analyzer cargo ron 0.12.0 value/Value#Seq#(vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![ |
| 115 | Valuerust-analyzer cargo ron 0.12.0 value/Value#::Numberrust-analyzer cargo ron 0.12.0 value/Value#Number#(Numberrust-analyzer cargo ron 0.12.0 value/number/Number#::U8rust-analyzer cargo ron 0.12.0 value/number/Number#U8#(1)), |
| 116 | Valuerust-analyzer cargo ron 0.12.0 value/Value#::Numberrust-analyzer cargo ron 0.12.0 value/Value#Number#(Numberrust-analyzer cargo ron 0.12.0 value/number/Number#::newrust-analyzer cargo ron 0.12.0 value/number/impl#[Number]new().(2f32)), |
| 117 | ]); |
| 118 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(ronrust-analyzer cargo ron 0.12.0 crate/::to_stringrust-analyzer cargo ron 0.12.0 ser/to_string().(&seq).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(), "[1,2.0]"); |
| 119 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!("[1, 2.0]".parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().(), Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(seq)); |
| 120 | |
| 121 | let err = Valuerust-analyzer cargo ron 0.12.0 value/Value#::Seqrust-analyzer cargo ron 0.12.0 value/Value#Seq#(vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![Valuerust-analyzer cargo ron 0.12.0 value/Value#::Numberrust-analyzer cargo ron 0.12.0 value/Value#Number#(Numberrust-analyzer cargo ron 0.12.0 value/number/Number#::newrust-analyzer cargo ron 0.12.0 value/number/impl#[Number]new().(1))]) |
| 122 | .into_rustrust-analyzer cargo ron 0.12.0 value/impl#[Value]into_rust().::<[i32; 2]>() |
| 123 | .unwrap_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap_err().(); |
| 124 | |
| 125 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 126 | err, |
| 127 | Errorrust-analyzer cargo ron 0.12.0 error/Error#::ExpectedDifferentLengthrust-analyzer cargo ron 0.12.0 error/Error#ExpectedDifferentLength# { |
| 128 | expectedrust-analyzer cargo ron 0.12.0 error/Error#ExpectedDifferentLength#expected.: 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().("an array of length 2"), |
| 129 | foundrust-analyzer cargo ron 0.12.0 error/Error#ExpectedDifferentLength#found.: 1, |
| 130 | } |
| 131 | ); |
| 132 | |
| 133 | let err = Valuerust-analyzer cargo ron 0.12.0 value/Value#::Seqrust-analyzer cargo ron 0.12.0 value/Value#Seq#(vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![ |
| 134 | Valuerust-analyzer cargo ron 0.12.0 value/Value#::Numberrust-analyzer cargo ron 0.12.0 value/Value#Number#(Numberrust-analyzer cargo ron 0.12.0 value/number/Number#::newrust-analyzer cargo ron 0.12.0 value/number/impl#[Number]new().(1)), |
| 135 | Valuerust-analyzer cargo ron 0.12.0 value/Value#::Numberrust-analyzer cargo ron 0.12.0 value/Value#Number#(Numberrust-analyzer cargo ron 0.12.0 value/number/Number#::newrust-analyzer cargo ron 0.12.0 value/number/impl#[Number]new().(2)), |
| 136 | Valuerust-analyzer cargo ron 0.12.0 value/Value#::Numberrust-analyzer cargo ron 0.12.0 value/Value#Number#(Numberrust-analyzer cargo ron 0.12.0 value/number/Number#::newrust-analyzer cargo ron 0.12.0 value/number/impl#[Number]new().(3)), |
| 137 | ]) |
| 138 | .into_rustrust-analyzer cargo ron 0.12.0 value/impl#[Value]into_rust().::<[i32; 2]>() |
| 139 | .unwrap_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap_err().(); |
| 140 | |
| 141 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 142 | err, |
| 143 | Errorrust-analyzer cargo ron 0.12.0 error/Error#::ExpectedDifferentLengthrust-analyzer cargo ron 0.12.0 error/Error#ExpectedDifferentLength# { |
| 144 | expectedrust-analyzer cargo ron 0.12.0 error/Error#ExpectedDifferentLength#expected.: 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().("a sequence of length 2"), |
| 145 | foundrust-analyzer cargo ron 0.12.0 error/Error#ExpectedDifferentLength#found.: 3, |
| 146 | } |
| 147 | ); |
| 148 | } |
| 149 | |
| 150 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 151 | fn unitrust-analyzer cargo ron 0.12.0 unit().() { |
| 152 | use 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#, Spanrust-analyzer cargo ron 0.12.0 error/Span#, SpannedErrorrust-analyzer cargo ron 0.12.0 error/SpannedError#}; |
| 153 | |
| 154 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!("()".parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().(), Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Valuerust-analyzer cargo ron 0.12.0 value/Value#::Unitrust-analyzer cargo ron 0.12.0 value/Value#Unit#)); |
| 155 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!("Foo".parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().(), Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Valuerust-analyzer cargo ron 0.12.0 value/Value#::Unitrust-analyzer cargo ron 0.12.0 value/Value#Unit#)); |
| 156 | |
| 157 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 158 | "".parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().::<Valuerust-analyzer cargo ron 0.12.0 value/Value#>(), |
| 159 | Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(SpannedErrorrust-analyzer cargo ron 0.12.0 error/SpannedError# { |
| 160 | coderust-analyzer cargo ron 0.12.0 error/SpannedError#code.: Errorrust-analyzer cargo ron 0.12.0 error/Error#::Eofrust-analyzer cargo ron 0.12.0 error/Error#Eof#, |
| 161 | spanrust-analyzer cargo ron 0.12.0 error/SpannedError#span.: Spanrust-analyzer cargo ron 0.12.0 error/Span# { |
| 162 | startrust-analyzer cargo ron 0.12.0 error/Span#start.: 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 }, |
| 163 | endrust-analyzer cargo ron 0.12.0 error/Span#end.: Positionrust-analyzer cargo ron 0.12.0 error/Position# { colrust-analyzer cargo ron 0.12.0 error/Position#col.: 1, linerust-analyzer cargo ron 0.12.0 error/Position#line.: 1 } |
| 164 | } |
| 165 | }) |
| 166 | ); |
| 167 | |
| 168 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(ronrust-analyzer cargo ron 0.12.0 crate/::to_stringrust-analyzer cargo ron 0.12.0 ser/to_string().(&Valuerust-analyzer cargo ron 0.12.0 value/Value#::Unitrust-analyzer cargo ron 0.12.0 value/Value#Unit#).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(), "()"); |
| 169 | } |
| 170 | |
| 171 | #[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:, 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:, Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:)] |
| 172 | struct Scenerust-analyzer cargo ron 0.12.0 Scene#(Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<(u32, u32)>); |
| 173 | |
| 174 | #[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:, 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:, Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:)] |
| 175 | struct Scene2rust-analyzer cargo ron 0.12.0 Scene2# { |
| 176 | foorust-analyzer cargo ron 0.12.0 Scene2#foo.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<(u32, u32)>, |
| 177 | } |
| 178 | |
| 179 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 180 | fn roundtriprust-analyzer cargo ron 0.12.0 roundtrip().() { |
| 181 | use 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()., serrust-analyzer cargo ron 0.12.0 ser/::to_stringrust-analyzer cargo ron 0.12.0 ser/to_string().}; |
| 182 | |
| 183 | { |
| 184 | let v = Scene2rust-analyzer cargo ron 0.12.0 Scene2# { |
| 185 | foorust-analyzer cargo ron 0.12.0 Scene2#foo.: Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#((122, 13)), |
| 186 | }; |
| 187 | let s = to_stringrust-analyzer cargo ron 0.12.0 ser/to_string().(&v).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 188 | printlnrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/println!!("{}", s); |
| 189 | let val: Valuerust-analyzer cargo ron 0.12.0 value/Value# = from_strrust-analyzer cargo ron 0.12.0 de/from_str().(&s).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 190 | printlnrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/println!!("{:?}", val); |
| 191 | let v2 = val.into_rustrust-analyzer cargo ron 0.12.0 value/impl#[Value]into_rust().::<Scene2rust-analyzer cargo ron 0.12.0 Scene2#>(); |
| 192 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(v2, Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(v)); |
| 193 | } |
| 194 | { |
| 195 | let v = Scenerust-analyzer cargo ron 0.12.0 Scene#(Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#((13, 122))); |
| 196 | let s = to_stringrust-analyzer cargo ron 0.12.0 ser/to_string().(&v).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 197 | printlnrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/println!!("{}", s); |
| 198 | let val: Valuerust-analyzer cargo ron 0.12.0 value/Value# = from_strrust-analyzer cargo ron 0.12.0 de/from_str().(&s).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 199 | printlnrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/println!!("{:?}", val); |
| 200 | let v2 = val.into_rustrust-analyzer cargo ron 0.12.0 value/impl#[Value]into_rust().::<Scenerust-analyzer cargo ron 0.12.0 Scene#>(); |
| 201 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(v2, Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(v)); |
| 202 | } |
| 203 | { |
| 204 | let v = (42,); |
| 205 | let s = to_stringrust-analyzer cargo ron 0.12.0 ser/to_string().(&v).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 206 | printlnrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/println!!("{}", s); |
| 207 | let val: Valuerust-analyzer cargo ron 0.12.0 value/Value# = from_strrust-analyzer cargo ron 0.12.0 de/from_str().(&s).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 208 | printlnrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/println!!("{:?}", val); |
| 209 | let v2 = val.into_rustrust-analyzer cargo ron 0.12.0 value/impl#[Value]into_rust().::<(i32,)>(); |
| 210 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(v2, Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(v)); |
| 211 | } |
| 212 | } |
| 213 | |
| 214 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 215 | fn map_roundtrip_338rust-analyzer cargo ron 0.12.0 map_roundtrip_338().() { |
| 216 | // https://github.com/ron-rs/ron/issues/338 |
| 217 | |
| 218 | let v: Valuerust-analyzer cargo ron 0.12.0 value/Value# = ronrust-analyzer cargo ron 0.12.0 crate/::from_strrust-analyzer cargo ron 0.12.0 de/from_str().("{}").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 219 | printlnrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/println!!("{:?}", v); |
| 220 | |
| 221 | let ser = ronrust-analyzer cargo ron 0.12.0 crate/::to_stringrust-analyzer cargo ron 0.12.0 ser/to_string().(&v).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 222 | printlnrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/println!!("{:?}", ser); |
| 223 | |
| 224 | let roundtrip = ronrust-analyzer cargo ron 0.12.0 crate/::from_strrust-analyzer cargo ron 0.12.0 de/from_str().(&ser).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 225 | printlnrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/println!!("{:?}", roundtrip); |
| 226 | |
| 227 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(v, roundtrip); |
| 228 | } |