/rust/registry/src/index.crates.io-6f17d22bba15001f/serde-1.0.152/src/de/impls.rs
Line | Count | Source (jump to first uncovered line) |
1 | | use lib::*; |
2 | | |
3 | | use de::{ |
4 | | Deserialize, Deserializer, EnumAccess, Error, SeqAccess, Unexpected, VariantAccess, Visitor, |
5 | | }; |
6 | | |
7 | | #[cfg(any(feature = "std", feature = "alloc", not(no_core_duration)))] |
8 | | use de::MapAccess; |
9 | | |
10 | | use seed::InPlaceSeed; |
11 | | |
12 | | #[cfg(any(feature = "std", feature = "alloc"))] |
13 | | use __private::size_hint; |
14 | | |
15 | | //////////////////////////////////////////////////////////////////////////////// |
16 | | |
17 | | struct UnitVisitor; |
18 | | |
19 | | impl<'de> Visitor<'de> for UnitVisitor { |
20 | | type Value = (); |
21 | | |
22 | 0 | fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { |
23 | 0 | formatter.write_str("unit") |
24 | 0 | } |
25 | | |
26 | 0 | fn visit_unit<E>(self) -> Result<Self::Value, E> |
27 | 0 | where |
28 | 0 | E: Error, |
29 | 0 | { |
30 | 0 | Ok(()) |
31 | 0 | } Unexecuted instantiation: <serde::de::impls::UnitVisitor as serde::de::Visitor>::visit_unit::<serde_json::error::Error> Unexecuted instantiation: <serde::de::impls::UnitVisitor as serde::de::Visitor>::visit_unit::<_> Unexecuted instantiation: <serde::de::impls::UnitVisitor as serde::de::Visitor>::visit_unit::<serde_json::error::Error> |
32 | | } |
33 | | |
34 | | impl<'de> Deserialize<'de> for () { |
35 | 0 | fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> |
36 | 0 | where |
37 | 0 | D: Deserializer<'de>, |
38 | 0 | { |
39 | 0 | deserializer.deserialize_unit(UnitVisitor) |
40 | 0 | } Unexecuted instantiation: <() as serde::de::Deserialize>::deserialize::<&mut serde_json::de::Deserializer<serde_json::read::SliceRead>> Unexecuted instantiation: <() as serde::de::Deserialize>::deserialize::<_> Unexecuted instantiation: <() as serde::de::Deserialize>::deserialize::<serde_json::value::Value> Unexecuted instantiation: <() as serde::de::Deserialize>::deserialize::<&serde_json::value::Value> |
41 | | } |
42 | | |
43 | | #[cfg(feature = "unstable")] |
44 | | impl<'de> Deserialize<'de> for ! { |
45 | | fn deserialize<D>(_deserializer: D) -> Result<Self, D::Error> |
46 | | where |
47 | | D: Deserializer<'de>, |
48 | | { |
49 | | Err(Error::custom("cannot deserialize `!`")) |
50 | | } |
51 | | } |
52 | | |
53 | | //////////////////////////////////////////////////////////////////////////////// |
54 | | |
55 | | struct BoolVisitor; |
56 | | |
57 | | impl<'de> Visitor<'de> for BoolVisitor { |
58 | | type Value = bool; |
59 | | |
60 | 0 | fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { |
61 | 0 | formatter.write_str("a boolean") |
62 | 0 | } |
63 | | |
64 | 0 | fn visit_bool<E>(self, v: bool) -> Result<Self::Value, E> |
65 | 0 | where |
66 | 0 | E: Error, |
67 | 0 | { |
68 | 0 | Ok(v) |
69 | 0 | } Unexecuted instantiation: <serde::de::impls::BoolVisitor as serde::de::Visitor>::visit_bool::<serde_json::error::Error> Unexecuted instantiation: <serde::de::impls::BoolVisitor as serde::de::Visitor>::visit_bool::<_> |
70 | | } |
71 | | |
72 | | impl<'de> Deserialize<'de> for bool { |
73 | 0 | fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> |
74 | 0 | where |
75 | 0 | D: Deserializer<'de>, |
76 | 0 | { |
77 | 0 | deserializer.deserialize_bool(BoolVisitor) |
78 | 0 | } Unexecuted instantiation: <bool as serde::de::Deserialize>::deserialize::<serde::__private::de::missing_field::MissingFieldDeserializer<serde_json::error::Error>> Unexecuted instantiation: <bool as serde::de::Deserialize>::deserialize::<&mut serde_json::de::Deserializer<serde_json::read::SliceRead>> Unexecuted instantiation: <bool as serde::de::Deserialize>::deserialize::<_> |
79 | | } |
80 | | |
81 | | //////////////////////////////////////////////////////////////////////////////// |
82 | | |
83 | | macro_rules! impl_deserialize_num { |
84 | | ($primitive:ident, $nonzero:ident $(cfg($($cfg:tt)*))*, $deserialize:ident $($method:ident!($($val:ident : $visit:ident)*);)*) => { |
85 | | impl_deserialize_num!($primitive, $deserialize $($method!($($val : $visit)*);)*); |
86 | | |
87 | | #[cfg(all(not(no_num_nonzero), $($($cfg)*)*))] |
88 | | impl<'de> Deserialize<'de> for num::$nonzero { |
89 | 0 | fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> |
90 | 0 | where |
91 | 0 | D: Deserializer<'de>, |
92 | 0 | { |
93 | | struct NonZeroVisitor; |
94 | | |
95 | | impl<'de> Visitor<'de> for NonZeroVisitor { |
96 | | type Value = num::$nonzero; |
97 | | |
98 | 0 | fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { |
99 | 0 | formatter.write_str(concat!("a nonzero ", stringify!($primitive))) |
100 | 0 | } Unexecuted instantiation: <<core::num::nonzero::NonZero<i8> as serde::de::Deserialize>::deserialize::NonZeroVisitor as serde::de::Visitor>::expecting Unexecuted instantiation: <<core::num::nonzero::NonZero<i16> as serde::de::Deserialize>::deserialize::NonZeroVisitor as serde::de::Visitor>::expecting Unexecuted instantiation: <<core::num::nonzero::NonZero<i32> as serde::de::Deserialize>::deserialize::NonZeroVisitor as serde::de::Visitor>::expecting Unexecuted instantiation: <<core::num::nonzero::NonZero<i64> as serde::de::Deserialize>::deserialize::NonZeroVisitor as serde::de::Visitor>::expecting Unexecuted instantiation: <<core::num::nonzero::NonZero<isize> as serde::de::Deserialize>::deserialize::NonZeroVisitor as serde::de::Visitor>::expecting Unexecuted instantiation: <<core::num::nonzero::NonZero<u8> as serde::de::Deserialize>::deserialize::NonZeroVisitor as serde::de::Visitor>::expecting Unexecuted instantiation: <<core::num::nonzero::NonZero<u16> as serde::de::Deserialize>::deserialize::NonZeroVisitor as serde::de::Visitor>::expecting Unexecuted instantiation: <<core::num::nonzero::NonZero<u32> as serde::de::Deserialize>::deserialize::NonZeroVisitor as serde::de::Visitor>::expecting Unexecuted instantiation: <<core::num::nonzero::NonZero<u64> as serde::de::Deserialize>::deserialize::NonZeroVisitor as serde::de::Visitor>::expecting Unexecuted instantiation: <<core::num::nonzero::NonZero<usize> as serde::de::Deserialize>::deserialize::NonZeroVisitor as serde::de::Visitor>::expecting Unexecuted instantiation: <<core::num::nonzero::NonZero<i128> as serde::de::Deserialize>::deserialize::NonZeroVisitor as serde::de::Visitor>::expecting Unexecuted instantiation: <<core::num::nonzero::NonZero<u128> as serde::de::Deserialize>::deserialize::NonZeroVisitor as serde::de::Visitor>::expecting |
101 | | |
102 | | $($($method!(nonzero $primitive $val : $visit);)*)* |
103 | | } |
104 | | |
105 | 0 | deserializer.$deserialize(NonZeroVisitor) |
106 | 0 | } Unexecuted instantiation: <core::num::nonzero::NonZero<i8> as serde::de::Deserialize>::deserialize::<_> Unexecuted instantiation: <core::num::nonzero::NonZero<i16> as serde::de::Deserialize>::deserialize::<_> Unexecuted instantiation: <core::num::nonzero::NonZero<i32> as serde::de::Deserialize>::deserialize::<_> Unexecuted instantiation: <core::num::nonzero::NonZero<i64> as serde::de::Deserialize>::deserialize::<_> Unexecuted instantiation: <core::num::nonzero::NonZero<isize> as serde::de::Deserialize>::deserialize::<_> Unexecuted instantiation: <core::num::nonzero::NonZero<u8> as serde::de::Deserialize>::deserialize::<_> Unexecuted instantiation: <core::num::nonzero::NonZero<u16> as serde::de::Deserialize>::deserialize::<_> Unexecuted instantiation: <core::num::nonzero::NonZero<u32> as serde::de::Deserialize>::deserialize::<_> Unexecuted instantiation: <core::num::nonzero::NonZero<u64> as serde::de::Deserialize>::deserialize::<_> Unexecuted instantiation: <core::num::nonzero::NonZero<usize> as serde::de::Deserialize>::deserialize::<_> Unexecuted instantiation: <core::num::nonzero::NonZero<i128> as serde::de::Deserialize>::deserialize::<_> Unexecuted instantiation: <core::num::nonzero::NonZero<u128> as serde::de::Deserialize>::deserialize::<_> |
107 | | } |
108 | | }; |
109 | | |
110 | | ($primitive:ident, $deserialize:ident $($method:ident!($($val:ident : $visit:ident)*);)*) => { |
111 | | impl<'de> Deserialize<'de> for $primitive { |
112 | | #[inline] |
113 | 0 | fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> |
114 | 0 | where |
115 | 0 | D: Deserializer<'de>, |
116 | 0 | { |
117 | | struct PrimitiveVisitor; |
118 | | |
119 | | impl<'de> Visitor<'de> for PrimitiveVisitor { |
120 | | type Value = $primitive; |
121 | | |
122 | 0 | fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { |
123 | 0 | formatter.write_str(stringify!($primitive)) |
124 | 0 | } Unexecuted instantiation: <<i8 as serde::de::Deserialize>::deserialize::PrimitiveVisitor as serde::de::Visitor>::expecting Unexecuted instantiation: <<i16 as serde::de::Deserialize>::deserialize::PrimitiveVisitor as serde::de::Visitor>::expecting Unexecuted instantiation: <<i32 as serde::de::Deserialize>::deserialize::PrimitiveVisitor as serde::de::Visitor>::expecting Unexecuted instantiation: <<i64 as serde::de::Deserialize>::deserialize::PrimitiveVisitor as serde::de::Visitor>::expecting Unexecuted instantiation: <<isize as serde::de::Deserialize>::deserialize::PrimitiveVisitor as serde::de::Visitor>::expecting Unexecuted instantiation: <<u8 as serde::de::Deserialize>::deserialize::PrimitiveVisitor as serde::de::Visitor>::expecting Unexecuted instantiation: <<u16 as serde::de::Deserialize>::deserialize::PrimitiveVisitor as serde::de::Visitor>::expecting Unexecuted instantiation: <<u32 as serde::de::Deserialize>::deserialize::PrimitiveVisitor as serde::de::Visitor>::expecting Unexecuted instantiation: <<u64 as serde::de::Deserialize>::deserialize::PrimitiveVisitor as serde::de::Visitor>::expecting Unexecuted instantiation: <<usize as serde::de::Deserialize>::deserialize::PrimitiveVisitor as serde::de::Visitor>::expecting Unexecuted instantiation: <<f32 as serde::de::Deserialize>::deserialize::PrimitiveVisitor as serde::de::Visitor>::expecting Unexecuted instantiation: <<f64 as serde::de::Deserialize>::deserialize::PrimitiveVisitor as serde::de::Visitor>::expecting Unexecuted instantiation: <<i128 as serde::de::Deserialize>::deserialize::PrimitiveVisitor as serde::de::Visitor>::expecting Unexecuted instantiation: <<u128 as serde::de::Deserialize>::deserialize::PrimitiveVisitor as serde::de::Visitor>::expecting |
125 | | |
126 | | $($($method!($val : $visit);)*)* |
127 | | } |
128 | | |
129 | 0 | deserializer.$deserialize(PrimitiveVisitor) |
130 | 0 | } Unexecuted instantiation: <usize as serde::de::Deserialize>::deserialize::<serde::__private::de::missing_field::MissingFieldDeserializer<serde_json::error::Error>> Unexecuted instantiation: <usize as serde::de::Deserialize>::deserialize::<&mut serde_json::de::Deserializer<serde_json::read::SliceRead>> Unexecuted instantiation: <i8 as serde::de::Deserialize>::deserialize::<_> Unexecuted instantiation: <i16 as serde::de::Deserialize>::deserialize::<_> Unexecuted instantiation: <i32 as serde::de::Deserialize>::deserialize::<_> Unexecuted instantiation: <i64 as serde::de::Deserialize>::deserialize::<_> Unexecuted instantiation: <isize as serde::de::Deserialize>::deserialize::<_> Unexecuted instantiation: <u8 as serde::de::Deserialize>::deserialize::<_> Unexecuted instantiation: <u16 as serde::de::Deserialize>::deserialize::<_> Unexecuted instantiation: <u32 as serde::de::Deserialize>::deserialize::<_> Unexecuted instantiation: <u64 as serde::de::Deserialize>::deserialize::<_> Unexecuted instantiation: <usize as serde::de::Deserialize>::deserialize::<_> Unexecuted instantiation: <f32 as serde::de::Deserialize>::deserialize::<_> Unexecuted instantiation: <f64 as serde::de::Deserialize>::deserialize::<_> Unexecuted instantiation: <i128 as serde::de::Deserialize>::deserialize::<_> Unexecuted instantiation: <u128 as serde::de::Deserialize>::deserialize::<_> |
131 | | } |
132 | | }; |
133 | | } |
134 | | |
135 | | macro_rules! num_self { |
136 | | ($ty:ident : $visit:ident) => { |
137 | | #[inline] |
138 | 0 | fn $visit<E>(self, v: $ty) -> Result<Self::Value, E> |
139 | 0 | where |
140 | 0 | E: Error, |
141 | 0 | { |
142 | 0 | Ok(v) |
143 | 0 | } Unexecuted instantiation: <<i8 as serde::de::Deserialize>::deserialize::PrimitiveVisitor as serde::de::Visitor>::visit_i8::<_> Unexecuted instantiation: <<i16 as serde::de::Deserialize>::deserialize::PrimitiveVisitor as serde::de::Visitor>::visit_i16::<_> Unexecuted instantiation: <<i32 as serde::de::Deserialize>::deserialize::PrimitiveVisitor as serde::de::Visitor>::visit_i32::<_> Unexecuted instantiation: <<i64 as serde::de::Deserialize>::deserialize::PrimitiveVisitor as serde::de::Visitor>::visit_i64::<_> Unexecuted instantiation: <<u8 as serde::de::Deserialize>::deserialize::PrimitiveVisitor as serde::de::Visitor>::visit_u8::<_> Unexecuted instantiation: <<u16 as serde::de::Deserialize>::deserialize::PrimitiveVisitor as serde::de::Visitor>::visit_u16::<_> Unexecuted instantiation: <<u32 as serde::de::Deserialize>::deserialize::PrimitiveVisitor as serde::de::Visitor>::visit_u32::<_> Unexecuted instantiation: <<u64 as serde::de::Deserialize>::deserialize::PrimitiveVisitor as serde::de::Visitor>::visit_u64::<_> Unexecuted instantiation: <<f32 as serde::de::Deserialize>::deserialize::PrimitiveVisitor as serde::de::Visitor>::visit_f32::<_> Unexecuted instantiation: <<f64 as serde::de::Deserialize>::deserialize::PrimitiveVisitor as serde::de::Visitor>::visit_f64::<_> Unexecuted instantiation: <<i128 as serde::de::Deserialize>::deserialize::PrimitiveVisitor as serde::de::Visitor>::visit_i128::<_> Unexecuted instantiation: <<u128 as serde::de::Deserialize>::deserialize::PrimitiveVisitor as serde::de::Visitor>::visit_u128::<_> |
144 | | }; |
145 | | |
146 | | (nonzero $primitive:ident $ty:ident : $visit:ident) => { |
147 | 0 | fn $visit<E>(self, v: $ty) -> Result<Self::Value, E> |
148 | 0 | where |
149 | 0 | E: Error, |
150 | 0 | { |
151 | 0 | if let Some(nonzero) = Self::Value::new(v) { |
152 | 0 | Ok(nonzero) |
153 | | } else { |
154 | 0 | Err(Error::invalid_value(Unexpected::Unsigned(0), &self)) |
155 | | } |
156 | 0 | } Unexecuted instantiation: <<core::num::nonzero::NonZero<i8> as serde::de::Deserialize>::deserialize::NonZeroVisitor as serde::de::Visitor>::visit_i8::<_> Unexecuted instantiation: <<core::num::nonzero::NonZero<i16> as serde::de::Deserialize>::deserialize::NonZeroVisitor as serde::de::Visitor>::visit_i16::<_> Unexecuted instantiation: <<core::num::nonzero::NonZero<i32> as serde::de::Deserialize>::deserialize::NonZeroVisitor as serde::de::Visitor>::visit_i32::<_> Unexecuted instantiation: <<core::num::nonzero::NonZero<i64> as serde::de::Deserialize>::deserialize::NonZeroVisitor as serde::de::Visitor>::visit_i64::<_> Unexecuted instantiation: <<core::num::nonzero::NonZero<u8> as serde::de::Deserialize>::deserialize::NonZeroVisitor as serde::de::Visitor>::visit_u8::<_> Unexecuted instantiation: <<core::num::nonzero::NonZero<u16> as serde::de::Deserialize>::deserialize::NonZeroVisitor as serde::de::Visitor>::visit_u16::<_> Unexecuted instantiation: <<core::num::nonzero::NonZero<u32> as serde::de::Deserialize>::deserialize::NonZeroVisitor as serde::de::Visitor>::visit_u32::<_> Unexecuted instantiation: <<core::num::nonzero::NonZero<u64> as serde::de::Deserialize>::deserialize::NonZeroVisitor as serde::de::Visitor>::visit_u64::<_> Unexecuted instantiation: <<core::num::nonzero::NonZero<i128> as serde::de::Deserialize>::deserialize::NonZeroVisitor as serde::de::Visitor>::visit_i128::<_> Unexecuted instantiation: <<core::num::nonzero::NonZero<u128> as serde::de::Deserialize>::deserialize::NonZeroVisitor as serde::de::Visitor>::visit_u128::<_> |
157 | | }; |
158 | | } |
159 | | |
160 | | macro_rules! num_as_self { |
161 | | ($ty:ident : $visit:ident) => { |
162 | | #[inline] |
163 | 0 | fn $visit<E>(self, v: $ty) -> Result<Self::Value, E> |
164 | 0 | where |
165 | 0 | E: Error, |
166 | 0 | { |
167 | 0 | Ok(v as Self::Value) |
168 | 0 | } Unexecuted instantiation: <<i16 as serde::de::Deserialize>::deserialize::PrimitiveVisitor as serde::de::Visitor>::visit_i8::<_> Unexecuted instantiation: <<i32 as serde::de::Deserialize>::deserialize::PrimitiveVisitor as serde::de::Visitor>::visit_i8::<_> Unexecuted instantiation: <<i32 as serde::de::Deserialize>::deserialize::PrimitiveVisitor as serde::de::Visitor>::visit_i16::<_> Unexecuted instantiation: <<i64 as serde::de::Deserialize>::deserialize::PrimitiveVisitor as serde::de::Visitor>::visit_i8::<_> Unexecuted instantiation: <<i64 as serde::de::Deserialize>::deserialize::PrimitiveVisitor as serde::de::Visitor>::visit_i16::<_> Unexecuted instantiation: <<i64 as serde::de::Deserialize>::deserialize::PrimitiveVisitor as serde::de::Visitor>::visit_i32::<_> Unexecuted instantiation: <<isize as serde::de::Deserialize>::deserialize::PrimitiveVisitor as serde::de::Visitor>::visit_i8::<_> Unexecuted instantiation: <<isize as serde::de::Deserialize>::deserialize::PrimitiveVisitor as serde::de::Visitor>::visit_i16::<_> Unexecuted instantiation: <<u16 as serde::de::Deserialize>::deserialize::PrimitiveVisitor as serde::de::Visitor>::visit_u8::<_> Unexecuted instantiation: <<u32 as serde::de::Deserialize>::deserialize::PrimitiveVisitor as serde::de::Visitor>::visit_u8::<_> Unexecuted instantiation: <<u32 as serde::de::Deserialize>::deserialize::PrimitiveVisitor as serde::de::Visitor>::visit_u16::<_> Unexecuted instantiation: <<u64 as serde::de::Deserialize>::deserialize::PrimitiveVisitor as serde::de::Visitor>::visit_u8::<_> Unexecuted instantiation: <<u64 as serde::de::Deserialize>::deserialize::PrimitiveVisitor as serde::de::Visitor>::visit_u16::<_> Unexecuted instantiation: <<u64 as serde::de::Deserialize>::deserialize::PrimitiveVisitor as serde::de::Visitor>::visit_u32::<_> Unexecuted instantiation: <<usize as serde::de::Deserialize>::deserialize::PrimitiveVisitor as serde::de::Visitor>::visit_u8::<_> Unexecuted instantiation: <<usize as serde::de::Deserialize>::deserialize::PrimitiveVisitor as serde::de::Visitor>::visit_u16::<_> Unexecuted instantiation: <<f32 as serde::de::Deserialize>::deserialize::PrimitiveVisitor as serde::de::Visitor>::visit_f64::<_> Unexecuted instantiation: <<f32 as serde::de::Deserialize>::deserialize::PrimitiveVisitor as serde::de::Visitor>::visit_i8::<_> Unexecuted instantiation: <<f32 as serde::de::Deserialize>::deserialize::PrimitiveVisitor as serde::de::Visitor>::visit_i16::<_> Unexecuted instantiation: <<f32 as serde::de::Deserialize>::deserialize::PrimitiveVisitor as serde::de::Visitor>::visit_i32::<_> Unexecuted instantiation: <<f32 as serde::de::Deserialize>::deserialize::PrimitiveVisitor as serde::de::Visitor>::visit_i64::<_> Unexecuted instantiation: <<f32 as serde::de::Deserialize>::deserialize::PrimitiveVisitor as serde::de::Visitor>::visit_u8::<_> Unexecuted instantiation: <<f32 as serde::de::Deserialize>::deserialize::PrimitiveVisitor as serde::de::Visitor>::visit_u16::<_> Unexecuted instantiation: <<f32 as serde::de::Deserialize>::deserialize::PrimitiveVisitor as serde::de::Visitor>::visit_u32::<_> Unexecuted instantiation: <<f32 as serde::de::Deserialize>::deserialize::PrimitiveVisitor as serde::de::Visitor>::visit_u64::<_> Unexecuted instantiation: <<f64 as serde::de::Deserialize>::deserialize::PrimitiveVisitor as serde::de::Visitor>::visit_f32::<_> Unexecuted instantiation: <<f64 as serde::de::Deserialize>::deserialize::PrimitiveVisitor as serde::de::Visitor>::visit_i8::<_> Unexecuted instantiation: <<f64 as serde::de::Deserialize>::deserialize::PrimitiveVisitor as serde::de::Visitor>::visit_i16::<_> Unexecuted instantiation: <<f64 as serde::de::Deserialize>::deserialize::PrimitiveVisitor as serde::de::Visitor>::visit_i32::<_> Unexecuted instantiation: <<f64 as serde::de::Deserialize>::deserialize::PrimitiveVisitor as serde::de::Visitor>::visit_i64::<_> Unexecuted instantiation: <<f64 as serde::de::Deserialize>::deserialize::PrimitiveVisitor as serde::de::Visitor>::visit_u8::<_> Unexecuted instantiation: <<f64 as serde::de::Deserialize>::deserialize::PrimitiveVisitor as serde::de::Visitor>::visit_u16::<_> Unexecuted instantiation: <<f64 as serde::de::Deserialize>::deserialize::PrimitiveVisitor as serde::de::Visitor>::visit_u32::<_> Unexecuted instantiation: <<f64 as serde::de::Deserialize>::deserialize::PrimitiveVisitor as serde::de::Visitor>::visit_u64::<_> Unexecuted instantiation: <<i128 as serde::de::Deserialize>::deserialize::PrimitiveVisitor as serde::de::Visitor>::visit_i8::<_> Unexecuted instantiation: <<i128 as serde::de::Deserialize>::deserialize::PrimitiveVisitor as serde::de::Visitor>::visit_i16::<_> Unexecuted instantiation: <<i128 as serde::de::Deserialize>::deserialize::PrimitiveVisitor as serde::de::Visitor>::visit_i32::<_> Unexecuted instantiation: <<i128 as serde::de::Deserialize>::deserialize::PrimitiveVisitor as serde::de::Visitor>::visit_i64::<_> Unexecuted instantiation: <<i128 as serde::de::Deserialize>::deserialize::PrimitiveVisitor as serde::de::Visitor>::visit_u8::<_> Unexecuted instantiation: <<i128 as serde::de::Deserialize>::deserialize::PrimitiveVisitor as serde::de::Visitor>::visit_u16::<_> Unexecuted instantiation: <<i128 as serde::de::Deserialize>::deserialize::PrimitiveVisitor as serde::de::Visitor>::visit_u32::<_> Unexecuted instantiation: <<i128 as serde::de::Deserialize>::deserialize::PrimitiveVisitor as serde::de::Visitor>::visit_u64::<_> Unexecuted instantiation: <<u128 as serde::de::Deserialize>::deserialize::PrimitiveVisitor as serde::de::Visitor>::visit_u8::<_> Unexecuted instantiation: <<u128 as serde::de::Deserialize>::deserialize::PrimitiveVisitor as serde::de::Visitor>::visit_u16::<_> Unexecuted instantiation: <<u128 as serde::de::Deserialize>::deserialize::PrimitiveVisitor as serde::de::Visitor>::visit_u32::<_> Unexecuted instantiation: <<u128 as serde::de::Deserialize>::deserialize::PrimitiveVisitor as serde::de::Visitor>::visit_u64::<_> |
169 | | }; |
170 | | |
171 | | (nonzero $primitive:ident $ty:ident : $visit:ident) => { |
172 | 0 | fn $visit<E>(self, v: $ty) -> Result<Self::Value, E> |
173 | 0 | where |
174 | 0 | E: Error, |
175 | 0 | { |
176 | 0 | if let Some(nonzero) = Self::Value::new(v as $primitive) { |
177 | 0 | Ok(nonzero) |
178 | | } else { |
179 | 0 | Err(Error::invalid_value(Unexpected::Unsigned(0), &self)) |
180 | | } |
181 | 0 | } Unexecuted instantiation: <<core::num::nonzero::NonZero<i16> as serde::de::Deserialize>::deserialize::NonZeroVisitor as serde::de::Visitor>::visit_i8::<_> Unexecuted instantiation: <<core::num::nonzero::NonZero<i32> as serde::de::Deserialize>::deserialize::NonZeroVisitor as serde::de::Visitor>::visit_i8::<_> Unexecuted instantiation: <<core::num::nonzero::NonZero<i32> as serde::de::Deserialize>::deserialize::NonZeroVisitor as serde::de::Visitor>::visit_i16::<_> Unexecuted instantiation: <<core::num::nonzero::NonZero<i64> as serde::de::Deserialize>::deserialize::NonZeroVisitor as serde::de::Visitor>::visit_i8::<_> Unexecuted instantiation: <<core::num::nonzero::NonZero<i64> as serde::de::Deserialize>::deserialize::NonZeroVisitor as serde::de::Visitor>::visit_i16::<_> Unexecuted instantiation: <<core::num::nonzero::NonZero<i64> as serde::de::Deserialize>::deserialize::NonZeroVisitor as serde::de::Visitor>::visit_i32::<_> Unexecuted instantiation: <<core::num::nonzero::NonZero<isize> as serde::de::Deserialize>::deserialize::NonZeroVisitor as serde::de::Visitor>::visit_i8::<_> Unexecuted instantiation: <<core::num::nonzero::NonZero<isize> as serde::de::Deserialize>::deserialize::NonZeroVisitor as serde::de::Visitor>::visit_i16::<_> Unexecuted instantiation: <<core::num::nonzero::NonZero<u16> as serde::de::Deserialize>::deserialize::NonZeroVisitor as serde::de::Visitor>::visit_u8::<_> Unexecuted instantiation: <<core::num::nonzero::NonZero<u32> as serde::de::Deserialize>::deserialize::NonZeroVisitor as serde::de::Visitor>::visit_u8::<_> Unexecuted instantiation: <<core::num::nonzero::NonZero<u32> as serde::de::Deserialize>::deserialize::NonZeroVisitor as serde::de::Visitor>::visit_u16::<_> Unexecuted instantiation: <<core::num::nonzero::NonZero<u64> as serde::de::Deserialize>::deserialize::NonZeroVisitor as serde::de::Visitor>::visit_u8::<_> Unexecuted instantiation: <<core::num::nonzero::NonZero<u64> as serde::de::Deserialize>::deserialize::NonZeroVisitor as serde::de::Visitor>::visit_u16::<_> Unexecuted instantiation: <<core::num::nonzero::NonZero<u64> as serde::de::Deserialize>::deserialize::NonZeroVisitor as serde::de::Visitor>::visit_u32::<_> Unexecuted instantiation: <<core::num::nonzero::NonZero<usize> as serde::de::Deserialize>::deserialize::NonZeroVisitor as serde::de::Visitor>::visit_u8::<_> Unexecuted instantiation: <<core::num::nonzero::NonZero<usize> as serde::de::Deserialize>::deserialize::NonZeroVisitor as serde::de::Visitor>::visit_u16::<_> Unexecuted instantiation: <<core::num::nonzero::NonZero<i128> as serde::de::Deserialize>::deserialize::NonZeroVisitor as serde::de::Visitor>::visit_i8::<_> Unexecuted instantiation: <<core::num::nonzero::NonZero<i128> as serde::de::Deserialize>::deserialize::NonZeroVisitor as serde::de::Visitor>::visit_i16::<_> Unexecuted instantiation: <<core::num::nonzero::NonZero<i128> as serde::de::Deserialize>::deserialize::NonZeroVisitor as serde::de::Visitor>::visit_i32::<_> Unexecuted instantiation: <<core::num::nonzero::NonZero<i128> as serde::de::Deserialize>::deserialize::NonZeroVisitor as serde::de::Visitor>::visit_i64::<_> Unexecuted instantiation: <<core::num::nonzero::NonZero<i128> as serde::de::Deserialize>::deserialize::NonZeroVisitor as serde::de::Visitor>::visit_u8::<_> Unexecuted instantiation: <<core::num::nonzero::NonZero<i128> as serde::de::Deserialize>::deserialize::NonZeroVisitor as serde::de::Visitor>::visit_u16::<_> Unexecuted instantiation: <<core::num::nonzero::NonZero<i128> as serde::de::Deserialize>::deserialize::NonZeroVisitor as serde::de::Visitor>::visit_u32::<_> Unexecuted instantiation: <<core::num::nonzero::NonZero<i128> as serde::de::Deserialize>::deserialize::NonZeroVisitor as serde::de::Visitor>::visit_u64::<_> Unexecuted instantiation: <<core::num::nonzero::NonZero<u128> as serde::de::Deserialize>::deserialize::NonZeroVisitor as serde::de::Visitor>::visit_u8::<_> Unexecuted instantiation: <<core::num::nonzero::NonZero<u128> as serde::de::Deserialize>::deserialize::NonZeroVisitor as serde::de::Visitor>::visit_u16::<_> Unexecuted instantiation: <<core::num::nonzero::NonZero<u128> as serde::de::Deserialize>::deserialize::NonZeroVisitor as serde::de::Visitor>::visit_u32::<_> Unexecuted instantiation: <<core::num::nonzero::NonZero<u128> as serde::de::Deserialize>::deserialize::NonZeroVisitor as serde::de::Visitor>::visit_u64::<_> |
182 | | }; |
183 | | } |
184 | | |
185 | | macro_rules! int_to_int { |
186 | | ($ty:ident : $visit:ident) => { |
187 | | #[inline] |
188 | 0 | fn $visit<E>(self, v: $ty) -> Result<Self::Value, E> |
189 | 0 | where |
190 | 0 | E: Error, |
191 | 0 | { |
192 | 0 | if Self::Value::min_value() as i64 <= v as i64 |
193 | 0 | && v as i64 <= Self::Value::max_value() as i64 |
194 | | { |
195 | 0 | Ok(v as Self::Value) |
196 | | } else { |
197 | 0 | Err(Error::invalid_value(Unexpected::Signed(v as i64), &self)) |
198 | | } |
199 | 0 | } Unexecuted instantiation: <<i8 as serde::de::Deserialize>::deserialize::PrimitiveVisitor as serde::de::Visitor>::visit_i16::<_> Unexecuted instantiation: <<i8 as serde::de::Deserialize>::deserialize::PrimitiveVisitor as serde::de::Visitor>::visit_i32::<_> Unexecuted instantiation: <<i8 as serde::de::Deserialize>::deserialize::PrimitiveVisitor as serde::de::Visitor>::visit_i64::<_> Unexecuted instantiation: <<i16 as serde::de::Deserialize>::deserialize::PrimitiveVisitor as serde::de::Visitor>::visit_i32::<_> Unexecuted instantiation: <<i16 as serde::de::Deserialize>::deserialize::PrimitiveVisitor as serde::de::Visitor>::visit_i64::<_> Unexecuted instantiation: <<i32 as serde::de::Deserialize>::deserialize::PrimitiveVisitor as serde::de::Visitor>::visit_i64::<_> Unexecuted instantiation: <<isize as serde::de::Deserialize>::deserialize::PrimitiveVisitor as serde::de::Visitor>::visit_i32::<_> Unexecuted instantiation: <<isize as serde::de::Deserialize>::deserialize::PrimitiveVisitor as serde::de::Visitor>::visit_i64::<_> |
200 | | }; |
201 | | |
202 | | (nonzero $primitive:ident $ty:ident : $visit:ident) => { |
203 | 0 | fn $visit<E>(self, v: $ty) -> Result<Self::Value, E> |
204 | 0 | where |
205 | 0 | E: Error, |
206 | 0 | { |
207 | 0 | if $primitive::min_value() as i64 <= v as i64 |
208 | 0 | && v as i64 <= $primitive::max_value() as i64 |
209 | | { |
210 | 0 | if let Some(nonzero) = Self::Value::new(v as $primitive) { |
211 | 0 | return Ok(nonzero); |
212 | 0 | } |
213 | 0 | } |
214 | 0 | Err(Error::invalid_value(Unexpected::Signed(v as i64), &self)) |
215 | 0 | } Unexecuted instantiation: <<core::num::nonzero::NonZero<i8> as serde::de::Deserialize>::deserialize::NonZeroVisitor as serde::de::Visitor>::visit_i16::<_> Unexecuted instantiation: <<core::num::nonzero::NonZero<i8> as serde::de::Deserialize>::deserialize::NonZeroVisitor as serde::de::Visitor>::visit_i32::<_> Unexecuted instantiation: <<core::num::nonzero::NonZero<i8> as serde::de::Deserialize>::deserialize::NonZeroVisitor as serde::de::Visitor>::visit_i64::<_> Unexecuted instantiation: <<core::num::nonzero::NonZero<i16> as serde::de::Deserialize>::deserialize::NonZeroVisitor as serde::de::Visitor>::visit_i32::<_> Unexecuted instantiation: <<core::num::nonzero::NonZero<i16> as serde::de::Deserialize>::deserialize::NonZeroVisitor as serde::de::Visitor>::visit_i64::<_> Unexecuted instantiation: <<core::num::nonzero::NonZero<i32> as serde::de::Deserialize>::deserialize::NonZeroVisitor as serde::de::Visitor>::visit_i64::<_> Unexecuted instantiation: <<core::num::nonzero::NonZero<isize> as serde::de::Deserialize>::deserialize::NonZeroVisitor as serde::de::Visitor>::visit_i32::<_> Unexecuted instantiation: <<core::num::nonzero::NonZero<isize> as serde::de::Deserialize>::deserialize::NonZeroVisitor as serde::de::Visitor>::visit_i64::<_> |
216 | | }; |
217 | | } |
218 | | |
219 | | macro_rules! int_to_uint { |
220 | | ($ty:ident : $visit:ident) => { |
221 | | #[inline] |
222 | 0 | fn $visit<E>(self, v: $ty) -> Result<Self::Value, E> |
223 | 0 | where |
224 | 0 | E: Error, |
225 | 0 | { |
226 | 0 | if 0 <= v && v as u64 <= Self::Value::max_value() as u64 { |
227 | 0 | Ok(v as Self::Value) |
228 | | } else { |
229 | 0 | Err(Error::invalid_value(Unexpected::Signed(v as i64), &self)) |
230 | | } |
231 | 0 | } Unexecuted instantiation: <<usize as serde::de::Deserialize>::deserialize::PrimitiveVisitor as serde::de::Visitor>::visit_i64::<serde_json::error::Error> Unexecuted instantiation: <<u8 as serde::de::Deserialize>::deserialize::PrimitiveVisitor as serde::de::Visitor>::visit_i8::<_> Unexecuted instantiation: <<u8 as serde::de::Deserialize>::deserialize::PrimitiveVisitor as serde::de::Visitor>::visit_i16::<_> Unexecuted instantiation: <<u8 as serde::de::Deserialize>::deserialize::PrimitiveVisitor as serde::de::Visitor>::visit_i32::<_> Unexecuted instantiation: <<u8 as serde::de::Deserialize>::deserialize::PrimitiveVisitor as serde::de::Visitor>::visit_i64::<_> Unexecuted instantiation: <<u16 as serde::de::Deserialize>::deserialize::PrimitiveVisitor as serde::de::Visitor>::visit_i8::<_> Unexecuted instantiation: <<u16 as serde::de::Deserialize>::deserialize::PrimitiveVisitor as serde::de::Visitor>::visit_i16::<_> Unexecuted instantiation: <<u16 as serde::de::Deserialize>::deserialize::PrimitiveVisitor as serde::de::Visitor>::visit_i32::<_> Unexecuted instantiation: <<u16 as serde::de::Deserialize>::deserialize::PrimitiveVisitor as serde::de::Visitor>::visit_i64::<_> Unexecuted instantiation: <<u32 as serde::de::Deserialize>::deserialize::PrimitiveVisitor as serde::de::Visitor>::visit_i8::<_> Unexecuted instantiation: <<u32 as serde::de::Deserialize>::deserialize::PrimitiveVisitor as serde::de::Visitor>::visit_i16::<_> Unexecuted instantiation: <<u32 as serde::de::Deserialize>::deserialize::PrimitiveVisitor as serde::de::Visitor>::visit_i32::<_> Unexecuted instantiation: <<u32 as serde::de::Deserialize>::deserialize::PrimitiveVisitor as serde::de::Visitor>::visit_i64::<_> Unexecuted instantiation: <<u64 as serde::de::Deserialize>::deserialize::PrimitiveVisitor as serde::de::Visitor>::visit_i8::<_> Unexecuted instantiation: <<u64 as serde::de::Deserialize>::deserialize::PrimitiveVisitor as serde::de::Visitor>::visit_i16::<_> Unexecuted instantiation: <<u64 as serde::de::Deserialize>::deserialize::PrimitiveVisitor as serde::de::Visitor>::visit_i32::<_> Unexecuted instantiation: <<u64 as serde::de::Deserialize>::deserialize::PrimitiveVisitor as serde::de::Visitor>::visit_i64::<_> Unexecuted instantiation: <<usize as serde::de::Deserialize>::deserialize::PrimitiveVisitor as serde::de::Visitor>::visit_i8::<_> Unexecuted instantiation: <<usize as serde::de::Deserialize>::deserialize::PrimitiveVisitor as serde::de::Visitor>::visit_i16::<_> Unexecuted instantiation: <<usize as serde::de::Deserialize>::deserialize::PrimitiveVisitor as serde::de::Visitor>::visit_i32::<_> Unexecuted instantiation: <<usize as serde::de::Deserialize>::deserialize::PrimitiveVisitor as serde::de::Visitor>::visit_i64::<_> Unexecuted instantiation: <<u128 as serde::de::Deserialize>::deserialize::PrimitiveVisitor as serde::de::Visitor>::visit_i8::<_> Unexecuted instantiation: <<u128 as serde::de::Deserialize>::deserialize::PrimitiveVisitor as serde::de::Visitor>::visit_i16::<_> Unexecuted instantiation: <<u128 as serde::de::Deserialize>::deserialize::PrimitiveVisitor as serde::de::Visitor>::visit_i32::<_> Unexecuted instantiation: <<u128 as serde::de::Deserialize>::deserialize::PrimitiveVisitor as serde::de::Visitor>::visit_i64::<_> |
232 | | }; |
233 | | |
234 | | (nonzero $primitive:ident $ty:ident : $visit:ident) => { |
235 | 0 | fn $visit<E>(self, v: $ty) -> Result<Self::Value, E> |
236 | 0 | where |
237 | 0 | E: Error, |
238 | 0 | { |
239 | 0 | if 0 < v && v as u64 <= $primitive::max_value() as u64 { |
240 | 0 | if let Some(nonzero) = Self::Value::new(v as $primitive) { |
241 | 0 | return Ok(nonzero); |
242 | 0 | } |
243 | 0 | } |
244 | 0 | Err(Error::invalid_value(Unexpected::Signed(v as i64), &self)) |
245 | 0 | } Unexecuted instantiation: <<core::num::nonzero::NonZero<u8> as serde::de::Deserialize>::deserialize::NonZeroVisitor as serde::de::Visitor>::visit_i8::<_> Unexecuted instantiation: <<core::num::nonzero::NonZero<u8> as serde::de::Deserialize>::deserialize::NonZeroVisitor as serde::de::Visitor>::visit_i16::<_> Unexecuted instantiation: <<core::num::nonzero::NonZero<u8> as serde::de::Deserialize>::deserialize::NonZeroVisitor as serde::de::Visitor>::visit_i32::<_> Unexecuted instantiation: <<core::num::nonzero::NonZero<u8> as serde::de::Deserialize>::deserialize::NonZeroVisitor as serde::de::Visitor>::visit_i64::<_> Unexecuted instantiation: <<core::num::nonzero::NonZero<u16> as serde::de::Deserialize>::deserialize::NonZeroVisitor as serde::de::Visitor>::visit_i8::<_> Unexecuted instantiation: <<core::num::nonzero::NonZero<u16> as serde::de::Deserialize>::deserialize::NonZeroVisitor as serde::de::Visitor>::visit_i16::<_> Unexecuted instantiation: <<core::num::nonzero::NonZero<u16> as serde::de::Deserialize>::deserialize::NonZeroVisitor as serde::de::Visitor>::visit_i32::<_> Unexecuted instantiation: <<core::num::nonzero::NonZero<u16> as serde::de::Deserialize>::deserialize::NonZeroVisitor as serde::de::Visitor>::visit_i64::<_> Unexecuted instantiation: <<core::num::nonzero::NonZero<u32> as serde::de::Deserialize>::deserialize::NonZeroVisitor as serde::de::Visitor>::visit_i8::<_> Unexecuted instantiation: <<core::num::nonzero::NonZero<u32> as serde::de::Deserialize>::deserialize::NonZeroVisitor as serde::de::Visitor>::visit_i16::<_> Unexecuted instantiation: <<core::num::nonzero::NonZero<u32> as serde::de::Deserialize>::deserialize::NonZeroVisitor as serde::de::Visitor>::visit_i32::<_> Unexecuted instantiation: <<core::num::nonzero::NonZero<u32> as serde::de::Deserialize>::deserialize::NonZeroVisitor as serde::de::Visitor>::visit_i64::<_> Unexecuted instantiation: <<core::num::nonzero::NonZero<u64> as serde::de::Deserialize>::deserialize::NonZeroVisitor as serde::de::Visitor>::visit_i8::<_> Unexecuted instantiation: <<core::num::nonzero::NonZero<u64> as serde::de::Deserialize>::deserialize::NonZeroVisitor as serde::de::Visitor>::visit_i16::<_> Unexecuted instantiation: <<core::num::nonzero::NonZero<u64> as serde::de::Deserialize>::deserialize::NonZeroVisitor as serde::de::Visitor>::visit_i32::<_> Unexecuted instantiation: <<core::num::nonzero::NonZero<u64> as serde::de::Deserialize>::deserialize::NonZeroVisitor as serde::de::Visitor>::visit_i64::<_> Unexecuted instantiation: <<core::num::nonzero::NonZero<usize> as serde::de::Deserialize>::deserialize::NonZeroVisitor as serde::de::Visitor>::visit_i8::<_> Unexecuted instantiation: <<core::num::nonzero::NonZero<usize> as serde::de::Deserialize>::deserialize::NonZeroVisitor as serde::de::Visitor>::visit_i16::<_> Unexecuted instantiation: <<core::num::nonzero::NonZero<usize> as serde::de::Deserialize>::deserialize::NonZeroVisitor as serde::de::Visitor>::visit_i32::<_> Unexecuted instantiation: <<core::num::nonzero::NonZero<usize> as serde::de::Deserialize>::deserialize::NonZeroVisitor as serde::de::Visitor>::visit_i64::<_> Unexecuted instantiation: <<core::num::nonzero::NonZero<u128> as serde::de::Deserialize>::deserialize::NonZeroVisitor as serde::de::Visitor>::visit_i8::<_> Unexecuted instantiation: <<core::num::nonzero::NonZero<u128> as serde::de::Deserialize>::deserialize::NonZeroVisitor as serde::de::Visitor>::visit_i16::<_> Unexecuted instantiation: <<core::num::nonzero::NonZero<u128> as serde::de::Deserialize>::deserialize::NonZeroVisitor as serde::de::Visitor>::visit_i32::<_> Unexecuted instantiation: <<core::num::nonzero::NonZero<u128> as serde::de::Deserialize>::deserialize::NonZeroVisitor as serde::de::Visitor>::visit_i64::<_> |
246 | | }; |
247 | | } |
248 | | |
249 | | macro_rules! uint_to_self { |
250 | | ($ty:ident : $visit:ident) => { |
251 | | #[inline] |
252 | 0 | fn $visit<E>(self, v: $ty) -> Result<Self::Value, E> |
253 | 0 | where |
254 | 0 | E: Error, |
255 | 0 | { |
256 | 0 | if v as u64 <= Self::Value::max_value() as u64 { |
257 | 0 | Ok(v as Self::Value) |
258 | | } else { |
259 | 0 | Err(Error::invalid_value(Unexpected::Unsigned(v as u64), &self)) |
260 | | } |
261 | 0 | } Unexecuted instantiation: <<usize as serde::de::Deserialize>::deserialize::PrimitiveVisitor as serde::de::Visitor>::visit_u64::<serde_json::error::Error> Unexecuted instantiation: <<i8 as serde::de::Deserialize>::deserialize::PrimitiveVisitor as serde::de::Visitor>::visit_u8::<_> Unexecuted instantiation: <<i8 as serde::de::Deserialize>::deserialize::PrimitiveVisitor as serde::de::Visitor>::visit_u16::<_> Unexecuted instantiation: <<i8 as serde::de::Deserialize>::deserialize::PrimitiveVisitor as serde::de::Visitor>::visit_u32::<_> Unexecuted instantiation: <<i8 as serde::de::Deserialize>::deserialize::PrimitiveVisitor as serde::de::Visitor>::visit_u64::<_> Unexecuted instantiation: <<i16 as serde::de::Deserialize>::deserialize::PrimitiveVisitor as serde::de::Visitor>::visit_u8::<_> Unexecuted instantiation: <<i16 as serde::de::Deserialize>::deserialize::PrimitiveVisitor as serde::de::Visitor>::visit_u16::<_> Unexecuted instantiation: <<i16 as serde::de::Deserialize>::deserialize::PrimitiveVisitor as serde::de::Visitor>::visit_u32::<_> Unexecuted instantiation: <<i16 as serde::de::Deserialize>::deserialize::PrimitiveVisitor as serde::de::Visitor>::visit_u64::<_> Unexecuted instantiation: <<i32 as serde::de::Deserialize>::deserialize::PrimitiveVisitor as serde::de::Visitor>::visit_u8::<_> Unexecuted instantiation: <<i32 as serde::de::Deserialize>::deserialize::PrimitiveVisitor as serde::de::Visitor>::visit_u16::<_> Unexecuted instantiation: <<i32 as serde::de::Deserialize>::deserialize::PrimitiveVisitor as serde::de::Visitor>::visit_u32::<_> Unexecuted instantiation: <<i32 as serde::de::Deserialize>::deserialize::PrimitiveVisitor as serde::de::Visitor>::visit_u64::<_> Unexecuted instantiation: <<i64 as serde::de::Deserialize>::deserialize::PrimitiveVisitor as serde::de::Visitor>::visit_u8::<_> Unexecuted instantiation: <<i64 as serde::de::Deserialize>::deserialize::PrimitiveVisitor as serde::de::Visitor>::visit_u16::<_> Unexecuted instantiation: <<i64 as serde::de::Deserialize>::deserialize::PrimitiveVisitor as serde::de::Visitor>::visit_u32::<_> Unexecuted instantiation: <<i64 as serde::de::Deserialize>::deserialize::PrimitiveVisitor as serde::de::Visitor>::visit_u64::<_> Unexecuted instantiation: <<isize as serde::de::Deserialize>::deserialize::PrimitiveVisitor as serde::de::Visitor>::visit_u8::<_> Unexecuted instantiation: <<isize as serde::de::Deserialize>::deserialize::PrimitiveVisitor as serde::de::Visitor>::visit_u16::<_> Unexecuted instantiation: <<isize as serde::de::Deserialize>::deserialize::PrimitiveVisitor as serde::de::Visitor>::visit_u32::<_> Unexecuted instantiation: <<isize as serde::de::Deserialize>::deserialize::PrimitiveVisitor as serde::de::Visitor>::visit_u64::<_> Unexecuted instantiation: <<u8 as serde::de::Deserialize>::deserialize::PrimitiveVisitor as serde::de::Visitor>::visit_u16::<_> Unexecuted instantiation: <<u8 as serde::de::Deserialize>::deserialize::PrimitiveVisitor as serde::de::Visitor>::visit_u32::<_> Unexecuted instantiation: <<u8 as serde::de::Deserialize>::deserialize::PrimitiveVisitor as serde::de::Visitor>::visit_u64::<_> Unexecuted instantiation: <<u16 as serde::de::Deserialize>::deserialize::PrimitiveVisitor as serde::de::Visitor>::visit_u32::<_> Unexecuted instantiation: <<u16 as serde::de::Deserialize>::deserialize::PrimitiveVisitor as serde::de::Visitor>::visit_u64::<_> Unexecuted instantiation: <<u32 as serde::de::Deserialize>::deserialize::PrimitiveVisitor as serde::de::Visitor>::visit_u64::<_> Unexecuted instantiation: <<usize as serde::de::Deserialize>::deserialize::PrimitiveVisitor as serde::de::Visitor>::visit_u32::<_> Unexecuted instantiation: <<usize as serde::de::Deserialize>::deserialize::PrimitiveVisitor as serde::de::Visitor>::visit_u64::<_> |
262 | | }; |
263 | | |
264 | | (nonzero $primitive:ident $ty:ident : $visit:ident) => { |
265 | 0 | fn $visit<E>(self, v: $ty) -> Result<Self::Value, E> |
266 | 0 | where |
267 | 0 | E: Error, |
268 | 0 | { |
269 | 0 | if v as u64 <= $primitive::max_value() as u64 { |
270 | 0 | if let Some(nonzero) = Self::Value::new(v as $primitive) { |
271 | 0 | return Ok(nonzero); |
272 | 0 | } |
273 | 0 | } |
274 | 0 | Err(Error::invalid_value(Unexpected::Unsigned(v as u64), &self)) |
275 | 0 | } Unexecuted instantiation: <<core::num::nonzero::NonZero<i8> as serde::de::Deserialize>::deserialize::NonZeroVisitor as serde::de::Visitor>::visit_u8::<_> Unexecuted instantiation: <<core::num::nonzero::NonZero<i8> as serde::de::Deserialize>::deserialize::NonZeroVisitor as serde::de::Visitor>::visit_u16::<_> Unexecuted instantiation: <<core::num::nonzero::NonZero<i8> as serde::de::Deserialize>::deserialize::NonZeroVisitor as serde::de::Visitor>::visit_u32::<_> Unexecuted instantiation: <<core::num::nonzero::NonZero<i8> as serde::de::Deserialize>::deserialize::NonZeroVisitor as serde::de::Visitor>::visit_u64::<_> Unexecuted instantiation: <<core::num::nonzero::NonZero<i16> as serde::de::Deserialize>::deserialize::NonZeroVisitor as serde::de::Visitor>::visit_u8::<_> Unexecuted instantiation: <<core::num::nonzero::NonZero<i16> as serde::de::Deserialize>::deserialize::NonZeroVisitor as serde::de::Visitor>::visit_u16::<_> Unexecuted instantiation: <<core::num::nonzero::NonZero<i16> as serde::de::Deserialize>::deserialize::NonZeroVisitor as serde::de::Visitor>::visit_u32::<_> Unexecuted instantiation: <<core::num::nonzero::NonZero<i16> as serde::de::Deserialize>::deserialize::NonZeroVisitor as serde::de::Visitor>::visit_u64::<_> Unexecuted instantiation: <<core::num::nonzero::NonZero<i32> as serde::de::Deserialize>::deserialize::NonZeroVisitor as serde::de::Visitor>::visit_u8::<_> Unexecuted instantiation: <<core::num::nonzero::NonZero<i32> as serde::de::Deserialize>::deserialize::NonZeroVisitor as serde::de::Visitor>::visit_u16::<_> Unexecuted instantiation: <<core::num::nonzero::NonZero<i32> as serde::de::Deserialize>::deserialize::NonZeroVisitor as serde::de::Visitor>::visit_u32::<_> Unexecuted instantiation: <<core::num::nonzero::NonZero<i32> as serde::de::Deserialize>::deserialize::NonZeroVisitor as serde::de::Visitor>::visit_u64::<_> Unexecuted instantiation: <<core::num::nonzero::NonZero<i64> as serde::de::Deserialize>::deserialize::NonZeroVisitor as serde::de::Visitor>::visit_u8::<_> Unexecuted instantiation: <<core::num::nonzero::NonZero<i64> as serde::de::Deserialize>::deserialize::NonZeroVisitor as serde::de::Visitor>::visit_u16::<_> Unexecuted instantiation: <<core::num::nonzero::NonZero<i64> as serde::de::Deserialize>::deserialize::NonZeroVisitor as serde::de::Visitor>::visit_u32::<_> Unexecuted instantiation: <<core::num::nonzero::NonZero<i64> as serde::de::Deserialize>::deserialize::NonZeroVisitor as serde::de::Visitor>::visit_u64::<_> Unexecuted instantiation: <<core::num::nonzero::NonZero<isize> as serde::de::Deserialize>::deserialize::NonZeroVisitor as serde::de::Visitor>::visit_u8::<_> Unexecuted instantiation: <<core::num::nonzero::NonZero<isize> as serde::de::Deserialize>::deserialize::NonZeroVisitor as serde::de::Visitor>::visit_u16::<_> Unexecuted instantiation: <<core::num::nonzero::NonZero<isize> as serde::de::Deserialize>::deserialize::NonZeroVisitor as serde::de::Visitor>::visit_u32::<_> Unexecuted instantiation: <<core::num::nonzero::NonZero<isize> as serde::de::Deserialize>::deserialize::NonZeroVisitor as serde::de::Visitor>::visit_u64::<_> Unexecuted instantiation: <<core::num::nonzero::NonZero<u8> as serde::de::Deserialize>::deserialize::NonZeroVisitor as serde::de::Visitor>::visit_u16::<_> Unexecuted instantiation: <<core::num::nonzero::NonZero<u8> as serde::de::Deserialize>::deserialize::NonZeroVisitor as serde::de::Visitor>::visit_u32::<_> Unexecuted instantiation: <<core::num::nonzero::NonZero<u8> as serde::de::Deserialize>::deserialize::NonZeroVisitor as serde::de::Visitor>::visit_u64::<_> Unexecuted instantiation: <<core::num::nonzero::NonZero<u16> as serde::de::Deserialize>::deserialize::NonZeroVisitor as serde::de::Visitor>::visit_u32::<_> Unexecuted instantiation: <<core::num::nonzero::NonZero<u16> as serde::de::Deserialize>::deserialize::NonZeroVisitor as serde::de::Visitor>::visit_u64::<_> Unexecuted instantiation: <<core::num::nonzero::NonZero<u32> as serde::de::Deserialize>::deserialize::NonZeroVisitor as serde::de::Visitor>::visit_u64::<_> Unexecuted instantiation: <<core::num::nonzero::NonZero<usize> as serde::de::Deserialize>::deserialize::NonZeroVisitor as serde::de::Visitor>::visit_u32::<_> Unexecuted instantiation: <<core::num::nonzero::NonZero<usize> as serde::de::Deserialize>::deserialize::NonZeroVisitor as serde::de::Visitor>::visit_u64::<_> |
276 | | }; |
277 | | } |
278 | | |
279 | | impl_deserialize_num! { |
280 | | i8, NonZeroI8 cfg(not(no_num_nonzero_signed)), deserialize_i8 |
281 | | num_self!(i8:visit_i8); |
282 | | int_to_int!(i16:visit_i16 i32:visit_i32 i64:visit_i64); |
283 | | uint_to_self!(u8:visit_u8 u16:visit_u16 u32:visit_u32 u64:visit_u64); |
284 | | } |
285 | | |
286 | | impl_deserialize_num! { |
287 | | i16, NonZeroI16 cfg(not(no_num_nonzero_signed)), deserialize_i16 |
288 | | num_self!(i16:visit_i16); |
289 | | num_as_self!(i8:visit_i8); |
290 | | int_to_int!(i32:visit_i32 i64:visit_i64); |
291 | | uint_to_self!(u8:visit_u8 u16:visit_u16 u32:visit_u32 u64:visit_u64); |
292 | | } |
293 | | |
294 | | impl_deserialize_num! { |
295 | | i32, NonZeroI32 cfg(not(no_num_nonzero_signed)), deserialize_i32 |
296 | | num_self!(i32:visit_i32); |
297 | | num_as_self!(i8:visit_i8 i16:visit_i16); |
298 | | int_to_int!(i64:visit_i64); |
299 | | uint_to_self!(u8:visit_u8 u16:visit_u16 u32:visit_u32 u64:visit_u64); |
300 | | } |
301 | | |
302 | | impl_deserialize_num! { |
303 | | i64, NonZeroI64 cfg(not(no_num_nonzero_signed)), deserialize_i64 |
304 | | num_self!(i64:visit_i64); |
305 | | num_as_self!(i8:visit_i8 i16:visit_i16 i32:visit_i32); |
306 | | uint_to_self!(u8:visit_u8 u16:visit_u16 u32:visit_u32 u64:visit_u64); |
307 | | } |
308 | | |
309 | | impl_deserialize_num! { |
310 | | isize, NonZeroIsize cfg(not(no_num_nonzero_signed)), deserialize_i64 |
311 | | num_as_self!(i8:visit_i8 i16:visit_i16); |
312 | | int_to_int!(i32:visit_i32 i64:visit_i64); |
313 | | uint_to_self!(u8:visit_u8 u16:visit_u16 u32:visit_u32 u64:visit_u64); |
314 | | } |
315 | | |
316 | | impl_deserialize_num! { |
317 | | u8, NonZeroU8, deserialize_u8 |
318 | | num_self!(u8:visit_u8); |
319 | | int_to_uint!(i8:visit_i8 i16:visit_i16 i32:visit_i32 i64:visit_i64); |
320 | | uint_to_self!(u16:visit_u16 u32:visit_u32 u64:visit_u64); |
321 | | } |
322 | | |
323 | | impl_deserialize_num! { |
324 | | u16, NonZeroU16, deserialize_u16 |
325 | | num_self!(u16:visit_u16); |
326 | | num_as_self!(u8:visit_u8); |
327 | | int_to_uint!(i8:visit_i8 i16:visit_i16 i32:visit_i32 i64:visit_i64); |
328 | | uint_to_self!(u32:visit_u32 u64:visit_u64); |
329 | | } |
330 | | |
331 | | impl_deserialize_num! { |
332 | | u32, NonZeroU32, deserialize_u32 |
333 | | num_self!(u32:visit_u32); |
334 | | num_as_self!(u8:visit_u8 u16:visit_u16); |
335 | | int_to_uint!(i8:visit_i8 i16:visit_i16 i32:visit_i32 i64:visit_i64); |
336 | | uint_to_self!(u64:visit_u64); |
337 | | } |
338 | | |
339 | | impl_deserialize_num! { |
340 | | u64, NonZeroU64, deserialize_u64 |
341 | | num_self!(u64:visit_u64); |
342 | | num_as_self!(u8:visit_u8 u16:visit_u16 u32:visit_u32); |
343 | | int_to_uint!(i8:visit_i8 i16:visit_i16 i32:visit_i32 i64:visit_i64); |
344 | | } |
345 | | |
346 | | impl_deserialize_num! { |
347 | | usize, NonZeroUsize, deserialize_u64 |
348 | | num_as_self!(u8:visit_u8 u16:visit_u16); |
349 | | int_to_uint!(i8:visit_i8 i16:visit_i16 i32:visit_i32 i64:visit_i64); |
350 | | uint_to_self!(u32:visit_u32 u64:visit_u64); |
351 | | } |
352 | | |
353 | | impl_deserialize_num! { |
354 | | f32, deserialize_f32 |
355 | | num_self!(f32:visit_f32); |
356 | | num_as_self!(f64:visit_f64); |
357 | | num_as_self!(i8:visit_i8 i16:visit_i16 i32:visit_i32 i64:visit_i64); |
358 | | num_as_self!(u8:visit_u8 u16:visit_u16 u32:visit_u32 u64:visit_u64); |
359 | | } |
360 | | |
361 | | impl_deserialize_num! { |
362 | | f64, deserialize_f64 |
363 | | num_self!(f64:visit_f64); |
364 | | num_as_self!(f32:visit_f32); |
365 | | num_as_self!(i8:visit_i8 i16:visit_i16 i32:visit_i32 i64:visit_i64); |
366 | | num_as_self!(u8:visit_u8 u16:visit_u16 u32:visit_u32 u64:visit_u64); |
367 | | } |
368 | | |
369 | | serde_if_integer128! { |
370 | | macro_rules! num_128 { |
371 | | ($ty:ident : $visit:ident) => { |
372 | 0 | fn $visit<E>(self, v: $ty) -> Result<Self::Value, E> |
373 | 0 | where |
374 | 0 | E: Error, |
375 | 0 | { |
376 | 0 | if v as i128 >= Self::Value::min_value() as i128 |
377 | 0 | && v as u128 <= Self::Value::max_value() as u128 |
378 | | { |
379 | 0 | Ok(v as Self::Value) |
380 | | } else { |
381 | 0 | Err(Error::invalid_value( |
382 | 0 | Unexpected::Other(stringify!($ty)), |
383 | 0 | &self, |
384 | 0 | )) |
385 | | } |
386 | 0 | } Unexecuted instantiation: <<i128 as serde::de::Deserialize>::deserialize::PrimitiveVisitor as serde::de::Visitor>::visit_u128::<_> Unexecuted instantiation: <<u128 as serde::de::Deserialize>::deserialize::PrimitiveVisitor as serde::de::Visitor>::visit_i128::<_> |
387 | | }; |
388 | | |
389 | | (nonzero $primitive:ident $ty:ident : $visit:ident) => { |
390 | 0 | fn $visit<E>(self, v: $ty) -> Result<Self::Value, E> |
391 | 0 | where |
392 | 0 | E: Error, |
393 | 0 | { |
394 | 0 | if v as i128 >= $primitive::min_value() as i128 |
395 | 0 | && v as u128 <= $primitive::max_value() as u128 |
396 | | { |
397 | 0 | if let Some(nonzero) = Self::Value::new(v as $primitive) { |
398 | 0 | Ok(nonzero) |
399 | | } else { |
400 | 0 | Err(Error::invalid_value(Unexpected::Unsigned(0), &self)) |
401 | | } |
402 | | } else { |
403 | 0 | Err(Error::invalid_value( |
404 | 0 | Unexpected::Other(stringify!($ty)), |
405 | 0 | &self, |
406 | 0 | )) |
407 | | } |
408 | 0 | } Unexecuted instantiation: <<core::num::nonzero::NonZero<i128> as serde::de::Deserialize>::deserialize::NonZeroVisitor as serde::de::Visitor>::visit_u128::<_> Unexecuted instantiation: <<core::num::nonzero::NonZero<u128> as serde::de::Deserialize>::deserialize::NonZeroVisitor as serde::de::Visitor>::visit_i128::<_> |
409 | | }; |
410 | | } |
411 | | |
412 | | impl_deserialize_num! { |
413 | | i128, NonZeroI128 cfg(not(no_num_nonzero_signed)), deserialize_i128 |
414 | | num_self!(i128:visit_i128); |
415 | | num_as_self!(i8:visit_i8 i16:visit_i16 i32:visit_i32 i64:visit_i64); |
416 | | num_as_self!(u8:visit_u8 u16:visit_u16 u32:visit_u32 u64:visit_u64); |
417 | | num_128!(u128:visit_u128); |
418 | | } |
419 | | |
420 | | impl_deserialize_num! { |
421 | | u128, NonZeroU128, deserialize_u128 |
422 | | num_self!(u128:visit_u128); |
423 | | num_as_self!(u8:visit_u8 u16:visit_u16 u32:visit_u32 u64:visit_u64); |
424 | | int_to_uint!(i8:visit_i8 i16:visit_i16 i32:visit_i32 i64:visit_i64); |
425 | | num_128!(i128:visit_i128); |
426 | | } |
427 | | } |
428 | | |
429 | | //////////////////////////////////////////////////////////////////////////////// |
430 | | |
431 | | struct CharVisitor; |
432 | | |
433 | | impl<'de> Visitor<'de> for CharVisitor { |
434 | | type Value = char; |
435 | | |
436 | 0 | fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { |
437 | 0 | formatter.write_str("a character") |
438 | 0 | } |
439 | | |
440 | | #[inline] |
441 | 0 | fn visit_char<E>(self, v: char) -> Result<Self::Value, E> |
442 | 0 | where |
443 | 0 | E: Error, |
444 | 0 | { |
445 | 0 | Ok(v) |
446 | 0 | } |
447 | | |
448 | | #[inline] |
449 | 0 | fn visit_str<E>(self, v: &str) -> Result<Self::Value, E> |
450 | 0 | where |
451 | 0 | E: Error, |
452 | 0 | { |
453 | 0 | let mut iter = v.chars(); |
454 | 0 | match (iter.next(), iter.next()) { |
455 | 0 | (Some(c), None) => Ok(c), |
456 | 0 | _ => Err(Error::invalid_value(Unexpected::Str(v), &self)), |
457 | | } |
458 | 0 | } |
459 | | } |
460 | | |
461 | | impl<'de> Deserialize<'de> for char { |
462 | | #[inline] |
463 | 0 | fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> |
464 | 0 | where |
465 | 0 | D: Deserializer<'de>, |
466 | 0 | { |
467 | 0 | deserializer.deserialize_char(CharVisitor) |
468 | 0 | } |
469 | | } |
470 | | |
471 | | //////////////////////////////////////////////////////////////////////////////// |
472 | | |
473 | | #[cfg(any(feature = "std", feature = "alloc"))] |
474 | | struct StringVisitor; |
475 | | #[cfg(any(feature = "std", feature = "alloc"))] |
476 | | struct StringInPlaceVisitor<'a>(&'a mut String); |
477 | | |
478 | | #[cfg(any(feature = "std", feature = "alloc"))] |
479 | | impl<'de> Visitor<'de> for StringVisitor { |
480 | | type Value = String; |
481 | | |
482 | 0 | fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { |
483 | 0 | formatter.write_str("a string") |
484 | 0 | } |
485 | | |
486 | 0 | fn visit_str<E>(self, v: &str) -> Result<Self::Value, E> |
487 | 0 | where |
488 | 0 | E: Error, |
489 | 0 | { |
490 | 0 | Ok(v.to_owned()) |
491 | 0 | } Unexecuted instantiation: <serde::de::impls::StringVisitor as serde::de::Visitor>::visit_str::<serde_json::error::Error> Unexecuted instantiation: <serde::de::impls::StringVisitor as serde::de::Visitor>::visit_str::<_> Unexecuted instantiation: <serde::de::impls::StringVisitor as serde::de::Visitor>::visit_str::<serde_json::error::Error> |
492 | | |
493 | 0 | fn visit_string<E>(self, v: String) -> Result<Self::Value, E> |
494 | 0 | where |
495 | 0 | E: Error, |
496 | 0 | { |
497 | 0 | Ok(v) |
498 | 0 | } |
499 | | |
500 | 0 | fn visit_bytes<E>(self, v: &[u8]) -> Result<Self::Value, E> |
501 | 0 | where |
502 | 0 | E: Error, |
503 | 0 | { |
504 | 0 | match str::from_utf8(v) { |
505 | 0 | Ok(s) => Ok(s.to_owned()), |
506 | 0 | Err(_) => Err(Error::invalid_value(Unexpected::Bytes(v), &self)), |
507 | | } |
508 | 0 | } |
509 | | |
510 | 0 | fn visit_byte_buf<E>(self, v: Vec<u8>) -> Result<Self::Value, E> |
511 | 0 | where |
512 | 0 | E: Error, |
513 | 0 | { |
514 | 0 | match String::from_utf8(v) { |
515 | 0 | Ok(s) => Ok(s), |
516 | 0 | Err(e) => Err(Error::invalid_value( |
517 | 0 | Unexpected::Bytes(&e.into_bytes()), |
518 | 0 | &self, |
519 | 0 | )), |
520 | | } |
521 | 0 | } |
522 | | } |
523 | | |
524 | | #[cfg(any(feature = "std", feature = "alloc"))] |
525 | | impl<'a, 'de> Visitor<'de> for StringInPlaceVisitor<'a> { |
526 | | type Value = (); |
527 | | |
528 | 0 | fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { |
529 | 0 | formatter.write_str("a string") |
530 | 0 | } |
531 | | |
532 | 0 | fn visit_str<E>(self, v: &str) -> Result<Self::Value, E> |
533 | 0 | where |
534 | 0 | E: Error, |
535 | 0 | { |
536 | 0 | self.0.clear(); |
537 | 0 | self.0.push_str(v); |
538 | 0 | Ok(()) |
539 | 0 | } |
540 | | |
541 | 0 | fn visit_string<E>(self, v: String) -> Result<Self::Value, E> |
542 | 0 | where |
543 | 0 | E: Error, |
544 | 0 | { |
545 | 0 | *self.0 = v; |
546 | 0 | Ok(()) |
547 | 0 | } |
548 | | |
549 | 0 | fn visit_bytes<E>(self, v: &[u8]) -> Result<Self::Value, E> |
550 | 0 | where |
551 | 0 | E: Error, |
552 | 0 | { |
553 | 0 | match str::from_utf8(v) { |
554 | 0 | Ok(s) => { |
555 | 0 | self.0.clear(); |
556 | 0 | self.0.push_str(s); |
557 | 0 | Ok(()) |
558 | | } |
559 | 0 | Err(_) => Err(Error::invalid_value(Unexpected::Bytes(v), &self)), |
560 | | } |
561 | 0 | } |
562 | | |
563 | 0 | fn visit_byte_buf<E>(self, v: Vec<u8>) -> Result<Self::Value, E> |
564 | 0 | where |
565 | 0 | E: Error, |
566 | 0 | { |
567 | 0 | match String::from_utf8(v) { |
568 | 0 | Ok(s) => { |
569 | 0 | *self.0 = s; |
570 | 0 | Ok(()) |
571 | | } |
572 | 0 | Err(e) => Err(Error::invalid_value( |
573 | 0 | Unexpected::Bytes(&e.into_bytes()), |
574 | 0 | &self, |
575 | 0 | )), |
576 | | } |
577 | 0 | } |
578 | | } |
579 | | |
580 | | #[cfg(any(feature = "std", feature = "alloc"))] |
581 | | impl<'de> Deserialize<'de> for String { |
582 | 0 | fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> |
583 | 0 | where |
584 | 0 | D: Deserializer<'de>, |
585 | 0 | { |
586 | 0 | deserializer.deserialize_string(StringVisitor) |
587 | 0 | } Unexecuted instantiation: <alloc::string::String as serde::de::Deserialize>::deserialize::<serde::__private::de::missing_field::MissingFieldDeserializer<serde_json::error::Error>> Unexecuted instantiation: <alloc::string::String as serde::de::Deserialize>::deserialize::<&mut serde_json::de::Deserializer<serde_json::read::SliceRead>> Unexecuted instantiation: <alloc::string::String as serde::de::Deserialize>::deserialize::<_> Unexecuted instantiation: <alloc::string::String as serde::de::Deserialize>::deserialize::<serde_json::de::MapKey<serde_json::read::StrRead>> |
588 | | |
589 | 0 | fn deserialize_in_place<D>(deserializer: D, place: &mut Self) -> Result<(), D::Error> |
590 | 0 | where |
591 | 0 | D: Deserializer<'de>, |
592 | 0 | { |
593 | 0 | deserializer.deserialize_string(StringInPlaceVisitor(place)) |
594 | 0 | } |
595 | | } |
596 | | |
597 | | //////////////////////////////////////////////////////////////////////////////// |
598 | | |
599 | | struct StrVisitor; |
600 | | |
601 | | impl<'a> Visitor<'a> for StrVisitor { |
602 | | type Value = &'a str; |
603 | | |
604 | 0 | fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { |
605 | 0 | formatter.write_str("a borrowed string") |
606 | 0 | } |
607 | | |
608 | 0 | fn visit_borrowed_str<E>(self, v: &'a str) -> Result<Self::Value, E> |
609 | 0 | where |
610 | 0 | E: Error, |
611 | 0 | { |
612 | 0 | Ok(v) // so easy |
613 | 0 | } |
614 | | |
615 | 0 | fn visit_borrowed_bytes<E>(self, v: &'a [u8]) -> Result<Self::Value, E> |
616 | 0 | where |
617 | 0 | E: Error, |
618 | 0 | { |
619 | 0 | str::from_utf8(v).map_err(|_| Error::invalid_value(Unexpected::Bytes(v), &self)) |
620 | 0 | } |
621 | | } |
622 | | |
623 | | impl<'de: 'a, 'a> Deserialize<'de> for &'a str { |
624 | 0 | fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> |
625 | 0 | where |
626 | 0 | D: Deserializer<'de>, |
627 | 0 | { |
628 | 0 | deserializer.deserialize_str(StrVisitor) |
629 | 0 | } |
630 | | } |
631 | | |
632 | | //////////////////////////////////////////////////////////////////////////////// |
633 | | |
634 | | struct BytesVisitor; |
635 | | |
636 | | impl<'a> Visitor<'a> for BytesVisitor { |
637 | | type Value = &'a [u8]; |
638 | | |
639 | 0 | fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { |
640 | 0 | formatter.write_str("a borrowed byte array") |
641 | 0 | } |
642 | | |
643 | 0 | fn visit_borrowed_bytes<E>(self, v: &'a [u8]) -> Result<Self::Value, E> |
644 | 0 | where |
645 | 0 | E: Error, |
646 | 0 | { |
647 | 0 | Ok(v) |
648 | 0 | } |
649 | | |
650 | 0 | fn visit_borrowed_str<E>(self, v: &'a str) -> Result<Self::Value, E> |
651 | 0 | where |
652 | 0 | E: Error, |
653 | 0 | { |
654 | 0 | Ok(v.as_bytes()) |
655 | 0 | } |
656 | | } |
657 | | |
658 | | impl<'de: 'a, 'a> Deserialize<'de> for &'a [u8] { |
659 | 0 | fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> |
660 | 0 | where |
661 | 0 | D: Deserializer<'de>, |
662 | 0 | { |
663 | 0 | deserializer.deserialize_bytes(BytesVisitor) |
664 | 0 | } |
665 | | } |
666 | | |
667 | | //////////////////////////////////////////////////////////////////////////////// |
668 | | |
669 | | #[cfg(feature = "std")] |
670 | | struct CStringVisitor; |
671 | | |
672 | | #[cfg(feature = "std")] |
673 | | impl<'de> Visitor<'de> for CStringVisitor { |
674 | | type Value = CString; |
675 | | |
676 | 0 | fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { |
677 | 0 | formatter.write_str("byte array") |
678 | 0 | } |
679 | | |
680 | 0 | fn visit_seq<A>(self, mut seq: A) -> Result<Self::Value, A::Error> |
681 | 0 | where |
682 | 0 | A: SeqAccess<'de>, |
683 | 0 | { |
684 | 0 | let len = size_hint::cautious(seq.size_hint()); |
685 | 0 | let mut values = Vec::with_capacity(len); |
686 | | |
687 | 0 | while let Some(value) = try!(seq.next_element()) { |
688 | 0 | values.push(value); |
689 | 0 | } |
690 | | |
691 | 0 | CString::new(values).map_err(Error::custom) |
692 | 0 | } |
693 | | |
694 | 0 | fn visit_bytes<E>(self, v: &[u8]) -> Result<Self::Value, E> |
695 | 0 | where |
696 | 0 | E: Error, |
697 | 0 | { |
698 | 0 | CString::new(v).map_err(Error::custom) |
699 | 0 | } |
700 | | |
701 | 0 | fn visit_byte_buf<E>(self, v: Vec<u8>) -> Result<Self::Value, E> |
702 | 0 | where |
703 | 0 | E: Error, |
704 | 0 | { |
705 | 0 | CString::new(v).map_err(Error::custom) |
706 | 0 | } |
707 | | |
708 | 0 | fn visit_str<E>(self, v: &str) -> Result<Self::Value, E> |
709 | 0 | where |
710 | 0 | E: Error, |
711 | 0 | { |
712 | 0 | CString::new(v).map_err(Error::custom) |
713 | 0 | } |
714 | | |
715 | 0 | fn visit_string<E>(self, v: String) -> Result<Self::Value, E> |
716 | 0 | where |
717 | 0 | E: Error, |
718 | 0 | { |
719 | 0 | CString::new(v).map_err(Error::custom) |
720 | 0 | } |
721 | | } |
722 | | |
723 | | #[cfg(feature = "std")] |
724 | | impl<'de> Deserialize<'de> for CString { |
725 | 0 | fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> |
726 | 0 | where |
727 | 0 | D: Deserializer<'de>, |
728 | 0 | { |
729 | 0 | deserializer.deserialize_byte_buf(CStringVisitor) |
730 | 0 | } |
731 | | } |
732 | | |
733 | | macro_rules! forwarded_impl { |
734 | | ( |
735 | | $(#[doc = $doc:tt])* |
736 | | ($($id:ident),*), $ty:ty, $func:expr |
737 | | ) => { |
738 | | $(#[doc = $doc])* |
739 | | impl<'de $(, $id : Deserialize<'de>,)*> Deserialize<'de> for $ty { |
740 | 0 | fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> |
741 | 0 | where |
742 | 0 | D: Deserializer<'de>, |
743 | 0 | { |
744 | 0 | Deserialize::deserialize(deserializer).map($func) |
745 | 0 | } Unexecuted instantiation: <alloc::boxed::Box<audio_processor::config::Processor> as serde::de::Deserialize>::deserialize::<serde::__private::de::missing_field::MissingFieldDeserializer<serde_json::error::Error>> Unexecuted instantiation: <alloc::boxed::Box<audio_processor::config::Processor> as serde::de::Deserialize>::deserialize::<&mut serde_json::de::Deserializer<serde_json::read::SliceRead>> Unexecuted instantiation: <alloc::boxed::Box<core::ffi::c_str::CStr> as serde::de::Deserialize>::deserialize::<_> Unexecuted instantiation: <core::cmp::Reverse<_> as serde::de::Deserialize>::deserialize::<_> Unexecuted instantiation: <alloc::boxed::Box<std::path::Path> as serde::de::Deserialize>::deserialize::<_> Unexecuted instantiation: <alloc::boxed::Box<_> as serde::de::Deserialize>::deserialize::<_> Unexecuted instantiation: <alloc::boxed::Box<[_]> as serde::de::Deserialize>::deserialize::<_> Unexecuted instantiation: <alloc::boxed::Box<str> as serde::de::Deserialize>::deserialize::<_> Unexecuted instantiation: <core::cell::RefCell<_> as serde::de::Deserialize>::deserialize::<_> Unexecuted instantiation: <std::sync::mutex::Mutex<_> as serde::de::Deserialize>::deserialize::<_> Unexecuted instantiation: <std::sync::rwlock::RwLock<_> as serde::de::Deserialize>::deserialize::<_> |
746 | | } |
747 | | } |
748 | | } |
749 | | |
750 | | #[cfg(all(feature = "std", not(no_de_boxed_c_str)))] |
751 | | forwarded_impl!((), Box<CStr>, CString::into_boxed_c_str); |
752 | | |
753 | | #[cfg(not(no_core_reverse))] |
754 | | forwarded_impl!((T), Reverse<T>, Reverse); |
755 | | |
756 | | //////////////////////////////////////////////////////////////////////////////// |
757 | | |
758 | | struct OptionVisitor<T> { |
759 | | marker: PhantomData<T>, |
760 | | } |
761 | | |
762 | | impl<'de, T> Visitor<'de> for OptionVisitor<T> |
763 | | where |
764 | | T: Deserialize<'de>, |
765 | | { |
766 | | type Value = Option<T>; |
767 | | |
768 | 0 | fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { |
769 | 0 | formatter.write_str("option") |
770 | 0 | } |
771 | | |
772 | | #[inline] |
773 | 0 | fn visit_unit<E>(self) -> Result<Self::Value, E> |
774 | 0 | where |
775 | 0 | E: Error, |
776 | 0 | { |
777 | 0 | Ok(None) |
778 | 0 | } |
779 | | |
780 | | #[inline] |
781 | 0 | fn visit_none<E>(self) -> Result<Self::Value, E> |
782 | 0 | where |
783 | 0 | E: Error, |
784 | 0 | { |
785 | 0 | Ok(None) |
786 | 0 | } Unexecuted instantiation: <serde::de::impls::OptionVisitor<usize> as serde::de::Visitor>::visit_none::<serde_json::error::Error> Unexecuted instantiation: <serde::de::impls::OptionVisitor<_> as serde::de::Visitor>::visit_none::<_> |
787 | | |
788 | | #[inline] |
789 | 0 | fn visit_some<D>(self, deserializer: D) -> Result<Self::Value, D::Error> |
790 | 0 | where |
791 | 0 | D: Deserializer<'de>, |
792 | 0 | { |
793 | 0 | T::deserialize(deserializer).map(Some) |
794 | 0 | } Unexecuted instantiation: <serde::de::impls::OptionVisitor<usize> as serde::de::Visitor>::visit_some::<&mut serde_json::de::Deserializer<serde_json::read::SliceRead>> Unexecuted instantiation: <serde::de::impls::OptionVisitor<_> as serde::de::Visitor>::visit_some::<_> |
795 | | |
796 | 0 | fn __private_visit_untagged_option<D>(self, deserializer: D) -> Result<Self::Value, ()> |
797 | 0 | where |
798 | 0 | D: Deserializer<'de>, |
799 | 0 | { |
800 | 0 | Ok(T::deserialize(deserializer).ok()) |
801 | 0 | } |
802 | | } |
803 | | |
804 | | impl<'de, T> Deserialize<'de> for Option<T> |
805 | | where |
806 | | T: Deserialize<'de>, |
807 | | { |
808 | 0 | fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> |
809 | 0 | where |
810 | 0 | D: Deserializer<'de>, |
811 | 0 | { |
812 | 0 | deserializer.deserialize_option(OptionVisitor { |
813 | 0 | marker: PhantomData, |
814 | 0 | }) |
815 | 0 | } Unexecuted instantiation: <core::option::Option<usize> as serde::de::Deserialize>::deserialize::<serde::__private::de::missing_field::MissingFieldDeserializer<serde_json::error::Error>> Unexecuted instantiation: <core::option::Option<usize> as serde::de::Deserialize>::deserialize::<&mut serde_json::de::Deserializer<serde_json::read::SliceRead>> Unexecuted instantiation: <core::option::Option<_> as serde::de::Deserialize>::deserialize::<_> |
816 | | |
817 | | // The Some variant's repr is opaque, so we can't play cute tricks with its |
818 | | // tag to have deserialize_in_place build the content in place unconditionally. |
819 | | // |
820 | | // FIXME: investigate whether branching on the old value being Some to |
821 | | // deserialize_in_place the value is profitable (probably data-dependent?) |
822 | | } |
823 | | |
824 | | //////////////////////////////////////////////////////////////////////////////// |
825 | | |
826 | | struct PhantomDataVisitor<T: ?Sized> { |
827 | | marker: PhantomData<T>, |
828 | | } |
829 | | |
830 | | impl<'de, T: ?Sized> Visitor<'de> for PhantomDataVisitor<T> { |
831 | | type Value = PhantomData<T>; |
832 | | |
833 | 0 | fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { |
834 | 0 | formatter.write_str("unit") |
835 | 0 | } |
836 | | |
837 | | #[inline] |
838 | 0 | fn visit_unit<E>(self) -> Result<Self::Value, E> |
839 | 0 | where |
840 | 0 | E: Error, |
841 | 0 | { |
842 | 0 | Ok(PhantomData) |
843 | 0 | } |
844 | | } |
845 | | |
846 | | impl<'de, T: ?Sized> Deserialize<'de> for PhantomData<T> { |
847 | 0 | fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> |
848 | 0 | where |
849 | 0 | D: Deserializer<'de>, |
850 | 0 | { |
851 | 0 | let visitor = PhantomDataVisitor { |
852 | 0 | marker: PhantomData, |
853 | 0 | }; |
854 | 0 | deserializer.deserialize_unit_struct("PhantomData", visitor) |
855 | 0 | } |
856 | | } |
857 | | |
858 | | //////////////////////////////////////////////////////////////////////////////// |
859 | | |
860 | | #[cfg(any(feature = "std", feature = "alloc"))] |
861 | | macro_rules! seq_impl { |
862 | | ( |
863 | | $ty:ident <T $(: $tbound1:ident $(+ $tbound2:ident)*)* $(, $typaram:ident : $bound1:ident $(+ $bound2:ident)*)*>, |
864 | | $access:ident, |
865 | | $clear:expr, |
866 | | $with_capacity:expr, |
867 | | $reserve:expr, |
868 | | $insert:expr |
869 | | ) => { |
870 | | impl<'de, T $(, $typaram)*> Deserialize<'de> for $ty<T $(, $typaram)*> |
871 | | where |
872 | | T: Deserialize<'de> $(+ $tbound1 $(+ $tbound2)*)*, |
873 | | $($typaram: $bound1 $(+ $bound2)*,)* |
874 | | { |
875 | 0 | fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> |
876 | 0 | where |
877 | 0 | D: Deserializer<'de>, |
878 | 0 | { |
879 | | struct SeqVisitor<T $(, $typaram)*> { |
880 | | marker: PhantomData<$ty<T $(, $typaram)*>>, |
881 | | } |
882 | | |
883 | | impl<'de, T $(, $typaram)*> Visitor<'de> for SeqVisitor<T $(, $typaram)*> |
884 | | where |
885 | | T: Deserialize<'de> $(+ $tbound1 $(+ $tbound2)*)*, |
886 | | $($typaram: $bound1 $(+ $bound2)*,)* |
887 | | { |
888 | | type Value = $ty<T $(, $typaram)*>; |
889 | | |
890 | 0 | fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { |
891 | 0 | formatter.write_str("a sequence") |
892 | 0 | } Unexecuted instantiation: <<alloc::collections::binary_heap::BinaryHeap<_> as serde::de::Deserialize>::deserialize::SeqVisitor<_> as serde::de::Visitor>::expecting Unexecuted instantiation: <<alloc::collections::btree::set::BTreeSet<_> as serde::de::Deserialize>::deserialize::SeqVisitor<_> as serde::de::Visitor>::expecting Unexecuted instantiation: <<alloc::collections::linked_list::LinkedList<_> as serde::de::Deserialize>::deserialize::SeqVisitor<_> as serde::de::Visitor>::expecting Unexecuted instantiation: <<std::collections::hash::set::HashSet<_, _> as serde::de::Deserialize>::deserialize::SeqVisitor<_, _> as serde::de::Visitor>::expecting Unexecuted instantiation: <<alloc::collections::vec_deque::VecDeque<_> as serde::de::Deserialize>::deserialize::SeqVisitor<_> as serde::de::Visitor>::expecting |
893 | | |
894 | | #[inline] |
895 | 0 | fn visit_seq<A>(self, mut $access: A) -> Result<Self::Value, A::Error> |
896 | 0 | where |
897 | 0 | A: SeqAccess<'de>, |
898 | 0 | { |
899 | 0 | let mut values = $with_capacity; |
900 | | |
901 | 0 | while let Some(value) = try!($access.next_element()) { |
902 | 0 | $insert(&mut values, value); |
903 | 0 | } |
904 | | |
905 | 0 | Ok(values) |
906 | 0 | } Unexecuted instantiation: <<alloc::collections::binary_heap::BinaryHeap<_> as serde::de::Deserialize>::deserialize::SeqVisitor<_> as serde::de::Visitor>::visit_seq::<_> Unexecuted instantiation: <<alloc::collections::btree::set::BTreeSet<_> as serde::de::Deserialize>::deserialize::SeqVisitor<_> as serde::de::Visitor>::visit_seq::<_> Unexecuted instantiation: <<alloc::collections::linked_list::LinkedList<_> as serde::de::Deserialize>::deserialize::SeqVisitor<_> as serde::de::Visitor>::visit_seq::<_> Unexecuted instantiation: <<std::collections::hash::set::HashSet<_, _> as serde::de::Deserialize>::deserialize::SeqVisitor<_, _> as serde::de::Visitor>::visit_seq::<_> Unexecuted instantiation: <<alloc::collections::vec_deque::VecDeque<_> as serde::de::Deserialize>::deserialize::SeqVisitor<_> as serde::de::Visitor>::visit_seq::<_> |
907 | | } |
908 | | |
909 | 0 | let visitor = SeqVisitor { marker: PhantomData }; |
910 | 0 | deserializer.deserialize_seq(visitor) |
911 | 0 | } Unexecuted instantiation: <alloc::collections::binary_heap::BinaryHeap<_> as serde::de::Deserialize>::deserialize::<_> Unexecuted instantiation: <alloc::collections::btree::set::BTreeSet<_> as serde::de::Deserialize>::deserialize::<_> Unexecuted instantiation: <alloc::collections::linked_list::LinkedList<_> as serde::de::Deserialize>::deserialize::<_> Unexecuted instantiation: <std::collections::hash::set::HashSet<_, _> as serde::de::Deserialize>::deserialize::<_> Unexecuted instantiation: <alloc::collections::vec_deque::VecDeque<_> as serde::de::Deserialize>::deserialize::<_> |
912 | | |
913 | 0 | fn deserialize_in_place<D>(deserializer: D, place: &mut Self) -> Result<(), D::Error> |
914 | 0 | where |
915 | 0 | D: Deserializer<'de>, |
916 | 0 | { |
917 | | struct SeqInPlaceVisitor<'a, T: 'a $(, $typaram: 'a)*>(&'a mut $ty<T $(, $typaram)*>); |
918 | | |
919 | | impl<'a, 'de, T $(, $typaram)*> Visitor<'de> for SeqInPlaceVisitor<'a, T $(, $typaram)*> |
920 | | where |
921 | | T: Deserialize<'de> $(+ $tbound1 $(+ $tbound2)*)*, |
922 | | $($typaram: $bound1 $(+ $bound2)*,)* |
923 | | { |
924 | | type Value = (); |
925 | | |
926 | 0 | fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { |
927 | 0 | formatter.write_str("a sequence") |
928 | 0 | } Unexecuted instantiation: <<alloc::collections::binary_heap::BinaryHeap<_> as serde::de::Deserialize>::deserialize_in_place::SeqInPlaceVisitor<_> as serde::de::Visitor>::expecting Unexecuted instantiation: <<alloc::collections::btree::set::BTreeSet<_> as serde::de::Deserialize>::deserialize_in_place::SeqInPlaceVisitor<_> as serde::de::Visitor>::expecting Unexecuted instantiation: <<alloc::collections::linked_list::LinkedList<_> as serde::de::Deserialize>::deserialize_in_place::SeqInPlaceVisitor<_> as serde::de::Visitor>::expecting Unexecuted instantiation: <<std::collections::hash::set::HashSet<_, _> as serde::de::Deserialize>::deserialize_in_place::SeqInPlaceVisitor<_, _> as serde::de::Visitor>::expecting Unexecuted instantiation: <<alloc::collections::vec_deque::VecDeque<_> as serde::de::Deserialize>::deserialize_in_place::SeqInPlaceVisitor<_> as serde::de::Visitor>::expecting |
929 | | |
930 | | #[inline] |
931 | 0 | fn visit_seq<A>(mut self, mut $access: A) -> Result<Self::Value, A::Error> |
932 | 0 | where |
933 | 0 | A: SeqAccess<'de>, |
934 | 0 | { |
935 | 0 | $clear(&mut self.0); |
936 | 0 | $reserve(&mut self.0, size_hint::cautious($access.size_hint())); |
937 | | |
938 | | // FIXME: try to overwrite old values here? (Vec, VecDeque, LinkedList) |
939 | 0 | while let Some(value) = try!($access.next_element()) { |
940 | 0 | $insert(&mut self.0, value); |
941 | 0 | } |
942 | | |
943 | 0 | Ok(()) |
944 | 0 | } Unexecuted instantiation: <<alloc::collections::binary_heap::BinaryHeap<_> as serde::de::Deserialize>::deserialize_in_place::SeqInPlaceVisitor<_> as serde::de::Visitor>::visit_seq::<_> Unexecuted instantiation: <<alloc::collections::btree::set::BTreeSet<_> as serde::de::Deserialize>::deserialize_in_place::SeqInPlaceVisitor<_> as serde::de::Visitor>::visit_seq::<_> Unexecuted instantiation: <<alloc::collections::linked_list::LinkedList<_> as serde::de::Deserialize>::deserialize_in_place::SeqInPlaceVisitor<_> as serde::de::Visitor>::visit_seq::<_> Unexecuted instantiation: <<std::collections::hash::set::HashSet<_, _> as serde::de::Deserialize>::deserialize_in_place::SeqInPlaceVisitor<_, _> as serde::de::Visitor>::visit_seq::<_> Unexecuted instantiation: <<alloc::collections::vec_deque::VecDeque<_> as serde::de::Deserialize>::deserialize_in_place::SeqInPlaceVisitor<_> as serde::de::Visitor>::visit_seq::<_> |
945 | | } |
946 | | |
947 | 0 | deserializer.deserialize_seq(SeqInPlaceVisitor(place)) |
948 | 0 | } Unexecuted instantiation: <alloc::collections::binary_heap::BinaryHeap<_> as serde::de::Deserialize>::deserialize_in_place::<_> Unexecuted instantiation: <alloc::collections::btree::set::BTreeSet<_> as serde::de::Deserialize>::deserialize_in_place::<_> Unexecuted instantiation: <alloc::collections::linked_list::LinkedList<_> as serde::de::Deserialize>::deserialize_in_place::<_> Unexecuted instantiation: <std::collections::hash::set::HashSet<_, _> as serde::de::Deserialize>::deserialize_in_place::<_> Unexecuted instantiation: <alloc::collections::vec_deque::VecDeque<_> as serde::de::Deserialize>::deserialize_in_place::<_> |
949 | | } |
950 | | } |
951 | | } |
952 | | |
953 | | // Dummy impl of reserve |
954 | | #[cfg(any(feature = "std", feature = "alloc"))] |
955 | 0 | fn nop_reserve<T>(_seq: T, _n: usize) {} |
956 | | |
957 | | #[cfg(any(feature = "std", feature = "alloc"))] |
958 | | seq_impl!( |
959 | | BinaryHeap<T: Ord>, |
960 | | seq, |
961 | | BinaryHeap::clear, |
962 | | BinaryHeap::with_capacity(size_hint::cautious(seq.size_hint())), |
963 | | BinaryHeap::reserve, |
964 | | BinaryHeap::push |
965 | | ); |
966 | | |
967 | | #[cfg(any(feature = "std", feature = "alloc"))] |
968 | | seq_impl!( |
969 | | BTreeSet<T: Eq + Ord>, |
970 | | seq, |
971 | | BTreeSet::clear, |
972 | | BTreeSet::new(), |
973 | | nop_reserve, |
974 | | BTreeSet::insert |
975 | | ); |
976 | | |
977 | | #[cfg(any(feature = "std", feature = "alloc"))] |
978 | | seq_impl!( |
979 | | LinkedList<T>, |
980 | | seq, |
981 | | LinkedList::clear, |
982 | | LinkedList::new(), |
983 | | nop_reserve, |
984 | | LinkedList::push_back |
985 | | ); |
986 | | |
987 | | #[cfg(feature = "std")] |
988 | | seq_impl!( |
989 | | HashSet<T: Eq + Hash, S: BuildHasher + Default>, |
990 | | seq, |
991 | | HashSet::clear, |
992 | | HashSet::with_capacity_and_hasher(size_hint::cautious(seq.size_hint()), S::default()), |
993 | | HashSet::reserve, |
994 | | HashSet::insert); |
995 | | |
996 | | #[cfg(any(feature = "std", feature = "alloc"))] |
997 | | seq_impl!( |
998 | | VecDeque<T>, |
999 | | seq, |
1000 | | VecDeque::clear, |
1001 | | VecDeque::with_capacity(size_hint::cautious(seq.size_hint())), |
1002 | | VecDeque::reserve, |
1003 | | VecDeque::push_back |
1004 | | ); |
1005 | | |
1006 | | //////////////////////////////////////////////////////////////////////////////// |
1007 | | |
1008 | | #[cfg(any(feature = "std", feature = "alloc"))] |
1009 | | impl<'de, T> Deserialize<'de> for Vec<T> |
1010 | | where |
1011 | | T: Deserialize<'de>, |
1012 | | { |
1013 | 0 | fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> |
1014 | 0 | where |
1015 | 0 | D: Deserializer<'de>, |
1016 | 0 | { |
1017 | | struct VecVisitor<T> { |
1018 | | marker: PhantomData<T>, |
1019 | | } |
1020 | | |
1021 | | impl<'de, T> Visitor<'de> for VecVisitor<T> |
1022 | | where |
1023 | | T: Deserialize<'de>, |
1024 | | { |
1025 | | type Value = Vec<T>; |
1026 | | |
1027 | 0 | fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { |
1028 | 0 | formatter.write_str("a sequence") |
1029 | 0 | } Unexecuted instantiation: <<alloc::vec::Vec<_> as serde::de::Deserialize>::deserialize::VecVisitor<audio_processor::config::Processor> as serde::de::Visitor>::expecting Unexecuted instantiation: <<alloc::vec::Vec<_> as serde::de::Deserialize>::deserialize::VecVisitor<usize> as serde::de::Visitor>::expecting Unexecuted instantiation: <<alloc::vec::Vec<_> as serde::de::Deserialize>::deserialize::VecVisitor<_> as serde::de::Visitor>::expecting |
1030 | | |
1031 | 0 | fn visit_seq<A>(self, mut seq: A) -> Result<Self::Value, A::Error> |
1032 | 0 | where |
1033 | 0 | A: SeqAccess<'de>, |
1034 | 0 | { |
1035 | 0 | let mut values = Vec::with_capacity(size_hint::cautious(seq.size_hint())); |
1036 | | |
1037 | 0 | while let Some(value) = try!(seq.next_element()) { |
1038 | 0 | values.push(value); |
1039 | 0 | } |
1040 | | |
1041 | 0 | Ok(values) |
1042 | 0 | } Unexecuted instantiation: <<alloc::vec::Vec<_> as serde::de::Deserialize>::deserialize::VecVisitor<audio_processor::config::Processor> as serde::de::Visitor>::visit_seq::<serde_json::de::SeqAccess<serde_json::read::SliceRead>> Unexecuted instantiation: <<alloc::vec::Vec<_> as serde::de::Deserialize>::deserialize::VecVisitor<usize> as serde::de::Visitor>::visit_seq::<serde_json::de::SeqAccess<serde_json::read::SliceRead>> Unexecuted instantiation: <<alloc::vec::Vec<_> as serde::de::Deserialize>::deserialize::VecVisitor<_> as serde::de::Visitor>::visit_seq::<_> |
1043 | | } |
1044 | | |
1045 | 0 | let visitor = VecVisitor { |
1046 | 0 | marker: PhantomData, |
1047 | 0 | }; |
1048 | 0 | deserializer.deserialize_seq(visitor) |
1049 | 0 | } Unexecuted instantiation: <alloc::vec::Vec<audio_processor::config::Processor> as serde::de::Deserialize>::deserialize::<serde::__private::de::missing_field::MissingFieldDeserializer<serde_json::error::Error>> Unexecuted instantiation: <alloc::vec::Vec<usize> as serde::de::Deserialize>::deserialize::<serde::__private::de::missing_field::MissingFieldDeserializer<serde_json::error::Error>> Unexecuted instantiation: <alloc::vec::Vec<audio_processor::config::Processor> as serde::de::Deserialize>::deserialize::<&mut serde_json::de::Deserializer<serde_json::read::SliceRead>> Unexecuted instantiation: <alloc::vec::Vec<usize> as serde::de::Deserialize>::deserialize::<&mut serde_json::de::Deserializer<serde_json::read::SliceRead>> Unexecuted instantiation: <alloc::vec::Vec<_> as serde::de::Deserialize>::deserialize::<_> |
1050 | | |
1051 | 0 | fn deserialize_in_place<D>(deserializer: D, place: &mut Self) -> Result<(), D::Error> |
1052 | 0 | where |
1053 | 0 | D: Deserializer<'de>, |
1054 | 0 | { |
1055 | | struct VecInPlaceVisitor<'a, T: 'a>(&'a mut Vec<T>); |
1056 | | |
1057 | | impl<'a, 'de, T> Visitor<'de> for VecInPlaceVisitor<'a, T> |
1058 | | where |
1059 | | T: Deserialize<'de>, |
1060 | | { |
1061 | | type Value = (); |
1062 | | |
1063 | 0 | fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { |
1064 | 0 | formatter.write_str("a sequence") |
1065 | 0 | } |
1066 | | |
1067 | 0 | fn visit_seq<A>(self, mut seq: A) -> Result<Self::Value, A::Error> |
1068 | 0 | where |
1069 | 0 | A: SeqAccess<'de>, |
1070 | 0 | { |
1071 | 0 | let hint = size_hint::cautious(seq.size_hint()); |
1072 | 0 | if let Some(additional) = hint.checked_sub(self.0.len()) { |
1073 | 0 | self.0.reserve(additional); |
1074 | 0 | } |
1075 | | |
1076 | 0 | for i in 0..self.0.len() { |
1077 | 0 | let next = { |
1078 | 0 | let next_place = InPlaceSeed(&mut self.0[i]); |
1079 | 0 | try!(seq.next_element_seed(next_place)) |
1080 | | }; |
1081 | 0 | if next.is_none() { |
1082 | 0 | self.0.truncate(i); |
1083 | 0 | return Ok(()); |
1084 | 0 | } |
1085 | | } |
1086 | | |
1087 | 0 | while let Some(value) = try!(seq.next_element()) { |
1088 | 0 | self.0.push(value); |
1089 | 0 | } |
1090 | | |
1091 | 0 | Ok(()) |
1092 | 0 | } |
1093 | | } |
1094 | | |
1095 | 0 | deserializer.deserialize_seq(VecInPlaceVisitor(place)) |
1096 | 0 | } |
1097 | | } |
1098 | | |
1099 | | //////////////////////////////////////////////////////////////////////////////// |
1100 | | |
1101 | | struct ArrayVisitor<A> { |
1102 | | marker: PhantomData<A>, |
1103 | | } |
1104 | | struct ArrayInPlaceVisitor<'a, A: 'a>(&'a mut A); |
1105 | | |
1106 | | impl<A> ArrayVisitor<A> { |
1107 | 0 | fn new() -> Self { |
1108 | 0 | ArrayVisitor { |
1109 | 0 | marker: PhantomData, |
1110 | 0 | } |
1111 | 0 | } |
1112 | | } |
1113 | | |
1114 | | impl<'de, T> Visitor<'de> for ArrayVisitor<[T; 0]> { |
1115 | | type Value = [T; 0]; |
1116 | | |
1117 | 0 | fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { |
1118 | 0 | formatter.write_str("an empty array") |
1119 | 0 | } |
1120 | | |
1121 | | #[inline] |
1122 | 0 | fn visit_seq<A>(self, _: A) -> Result<Self::Value, A::Error> |
1123 | 0 | where |
1124 | 0 | A: SeqAccess<'de>, |
1125 | 0 | { |
1126 | 0 | Ok([]) |
1127 | 0 | } |
1128 | | } |
1129 | | |
1130 | | // Does not require T: Deserialize<'de>. |
1131 | | impl<'de, T> Deserialize<'de> for [T; 0] { |
1132 | 0 | fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> |
1133 | 0 | where |
1134 | 0 | D: Deserializer<'de>, |
1135 | 0 | { |
1136 | 0 | deserializer.deserialize_tuple(0, ArrayVisitor::<[T; 0]>::new()) |
1137 | 0 | } |
1138 | | } |
1139 | | |
1140 | | macro_rules! array_impls { |
1141 | | ($($len:expr => ($($n:tt)+))+) => { |
1142 | | $( |
1143 | | impl<'de, T> Visitor<'de> for ArrayVisitor<[T; $len]> |
1144 | | where |
1145 | | T: Deserialize<'de>, |
1146 | | { |
1147 | | type Value = [T; $len]; |
1148 | | |
1149 | 0 | fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { |
1150 | 0 | formatter.write_str(concat!("an array of length ", $len)) |
1151 | 0 | } Unexecuted instantiation: <serde::de::impls::ArrayVisitor<[_; 1]> as serde::de::Visitor>::expecting Unexecuted instantiation: <serde::de::impls::ArrayVisitor<[_; 2]> as serde::de::Visitor>::expecting Unexecuted instantiation: <serde::de::impls::ArrayVisitor<[_; 3]> as serde::de::Visitor>::expecting Unexecuted instantiation: <serde::de::impls::ArrayVisitor<[_; 4]> as serde::de::Visitor>::expecting Unexecuted instantiation: <serde::de::impls::ArrayVisitor<[_; 5]> as serde::de::Visitor>::expecting Unexecuted instantiation: <serde::de::impls::ArrayVisitor<[_; 6]> as serde::de::Visitor>::expecting Unexecuted instantiation: <serde::de::impls::ArrayVisitor<[_; 7]> as serde::de::Visitor>::expecting Unexecuted instantiation: <serde::de::impls::ArrayVisitor<[_; 8]> as serde::de::Visitor>::expecting Unexecuted instantiation: <serde::de::impls::ArrayVisitor<[_; 9]> as serde::de::Visitor>::expecting Unexecuted instantiation: <serde::de::impls::ArrayVisitor<[_; 10]> as serde::de::Visitor>::expecting Unexecuted instantiation: <serde::de::impls::ArrayVisitor<[_; 11]> as serde::de::Visitor>::expecting Unexecuted instantiation: <serde::de::impls::ArrayVisitor<[_; 12]> as serde::de::Visitor>::expecting Unexecuted instantiation: <serde::de::impls::ArrayVisitor<[_; 13]> as serde::de::Visitor>::expecting Unexecuted instantiation: <serde::de::impls::ArrayVisitor<[_; 14]> as serde::de::Visitor>::expecting Unexecuted instantiation: <serde::de::impls::ArrayVisitor<[_; 15]> as serde::de::Visitor>::expecting Unexecuted instantiation: <serde::de::impls::ArrayVisitor<[_; 16]> as serde::de::Visitor>::expecting Unexecuted instantiation: <serde::de::impls::ArrayVisitor<[_; 17]> as serde::de::Visitor>::expecting Unexecuted instantiation: <serde::de::impls::ArrayVisitor<[_; 18]> as serde::de::Visitor>::expecting Unexecuted instantiation: <serde::de::impls::ArrayVisitor<[_; 19]> as serde::de::Visitor>::expecting Unexecuted instantiation: <serde::de::impls::ArrayVisitor<[_; 20]> as serde::de::Visitor>::expecting Unexecuted instantiation: <serde::de::impls::ArrayVisitor<[_; 21]> as serde::de::Visitor>::expecting Unexecuted instantiation: <serde::de::impls::ArrayVisitor<[_; 22]> as serde::de::Visitor>::expecting Unexecuted instantiation: <serde::de::impls::ArrayVisitor<[_; 23]> as serde::de::Visitor>::expecting Unexecuted instantiation: <serde::de::impls::ArrayVisitor<[_; 24]> as serde::de::Visitor>::expecting Unexecuted instantiation: <serde::de::impls::ArrayVisitor<[_; 25]> as serde::de::Visitor>::expecting Unexecuted instantiation: <serde::de::impls::ArrayVisitor<[_; 26]> as serde::de::Visitor>::expecting Unexecuted instantiation: <serde::de::impls::ArrayVisitor<[_; 27]> as serde::de::Visitor>::expecting Unexecuted instantiation: <serde::de::impls::ArrayVisitor<[_; 28]> as serde::de::Visitor>::expecting Unexecuted instantiation: <serde::de::impls::ArrayVisitor<[_; 29]> as serde::de::Visitor>::expecting Unexecuted instantiation: <serde::de::impls::ArrayVisitor<[_; 30]> as serde::de::Visitor>::expecting Unexecuted instantiation: <serde::de::impls::ArrayVisitor<[_; 31]> as serde::de::Visitor>::expecting Unexecuted instantiation: <serde::de::impls::ArrayVisitor<[_; 32]> as serde::de::Visitor>::expecting |
1152 | | |
1153 | | #[inline] |
1154 | 0 | fn visit_seq<A>(self, mut seq: A) -> Result<Self::Value, A::Error> |
1155 | 0 | where |
1156 | 0 | A: SeqAccess<'de>, |
1157 | 0 | { |
1158 | | Ok([$( |
1159 | 0 | match try!(seq.next_element()) { |
1160 | 0 | Some(val) => val, |
1161 | 0 | None => return Err(Error::invalid_length($n, &self)), |
1162 | | } |
1163 | | ),+]) |
1164 | 0 | } Unexecuted instantiation: <serde::de::impls::ArrayVisitor<[_; 1]> as serde::de::Visitor>::visit_seq::<_> Unexecuted instantiation: <serde::de::impls::ArrayVisitor<[_; 2]> as serde::de::Visitor>::visit_seq::<_> Unexecuted instantiation: <serde::de::impls::ArrayVisitor<[_; 3]> as serde::de::Visitor>::visit_seq::<_> Unexecuted instantiation: <serde::de::impls::ArrayVisitor<[_; 4]> as serde::de::Visitor>::visit_seq::<_> Unexecuted instantiation: <serde::de::impls::ArrayVisitor<[_; 5]> as serde::de::Visitor>::visit_seq::<_> Unexecuted instantiation: <serde::de::impls::ArrayVisitor<[_; 6]> as serde::de::Visitor>::visit_seq::<_> Unexecuted instantiation: <serde::de::impls::ArrayVisitor<[_; 7]> as serde::de::Visitor>::visit_seq::<_> Unexecuted instantiation: <serde::de::impls::ArrayVisitor<[_; 8]> as serde::de::Visitor>::visit_seq::<_> Unexecuted instantiation: <serde::de::impls::ArrayVisitor<[_; 9]> as serde::de::Visitor>::visit_seq::<_> Unexecuted instantiation: <serde::de::impls::ArrayVisitor<[_; 10]> as serde::de::Visitor>::visit_seq::<_> Unexecuted instantiation: <serde::de::impls::ArrayVisitor<[_; 11]> as serde::de::Visitor>::visit_seq::<_> Unexecuted instantiation: <serde::de::impls::ArrayVisitor<[_; 12]> as serde::de::Visitor>::visit_seq::<_> Unexecuted instantiation: <serde::de::impls::ArrayVisitor<[_; 13]> as serde::de::Visitor>::visit_seq::<_> Unexecuted instantiation: <serde::de::impls::ArrayVisitor<[_; 14]> as serde::de::Visitor>::visit_seq::<_> Unexecuted instantiation: <serde::de::impls::ArrayVisitor<[_; 15]> as serde::de::Visitor>::visit_seq::<_> Unexecuted instantiation: <serde::de::impls::ArrayVisitor<[_; 16]> as serde::de::Visitor>::visit_seq::<_> Unexecuted instantiation: <serde::de::impls::ArrayVisitor<[_; 17]> as serde::de::Visitor>::visit_seq::<_> Unexecuted instantiation: <serde::de::impls::ArrayVisitor<[_; 18]> as serde::de::Visitor>::visit_seq::<_> Unexecuted instantiation: <serde::de::impls::ArrayVisitor<[_; 19]> as serde::de::Visitor>::visit_seq::<_> Unexecuted instantiation: <serde::de::impls::ArrayVisitor<[_; 20]> as serde::de::Visitor>::visit_seq::<_> Unexecuted instantiation: <serde::de::impls::ArrayVisitor<[_; 21]> as serde::de::Visitor>::visit_seq::<_> Unexecuted instantiation: <serde::de::impls::ArrayVisitor<[_; 22]> as serde::de::Visitor>::visit_seq::<_> Unexecuted instantiation: <serde::de::impls::ArrayVisitor<[_; 23]> as serde::de::Visitor>::visit_seq::<_> Unexecuted instantiation: <serde::de::impls::ArrayVisitor<[_; 24]> as serde::de::Visitor>::visit_seq::<_> Unexecuted instantiation: <serde::de::impls::ArrayVisitor<[_; 25]> as serde::de::Visitor>::visit_seq::<_> Unexecuted instantiation: <serde::de::impls::ArrayVisitor<[_; 26]> as serde::de::Visitor>::visit_seq::<_> Unexecuted instantiation: <serde::de::impls::ArrayVisitor<[_; 27]> as serde::de::Visitor>::visit_seq::<_> Unexecuted instantiation: <serde::de::impls::ArrayVisitor<[_; 28]> as serde::de::Visitor>::visit_seq::<_> Unexecuted instantiation: <serde::de::impls::ArrayVisitor<[_; 29]> as serde::de::Visitor>::visit_seq::<_> Unexecuted instantiation: <serde::de::impls::ArrayVisitor<[_; 30]> as serde::de::Visitor>::visit_seq::<_> Unexecuted instantiation: <serde::de::impls::ArrayVisitor<[_; 31]> as serde::de::Visitor>::visit_seq::<_> Unexecuted instantiation: <serde::de::impls::ArrayVisitor<[_; 32]> as serde::de::Visitor>::visit_seq::<_> |
1165 | | } |
1166 | | |
1167 | | impl<'a, 'de, T> Visitor<'de> for ArrayInPlaceVisitor<'a, [T; $len]> |
1168 | | where |
1169 | | T: Deserialize<'de>, |
1170 | | { |
1171 | | type Value = (); |
1172 | | |
1173 | 0 | fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { |
1174 | 0 | formatter.write_str(concat!("an array of length ", $len)) |
1175 | 0 | } Unexecuted instantiation: <serde::de::impls::ArrayInPlaceVisitor<[_; 1]> as serde::de::Visitor>::expecting Unexecuted instantiation: <serde::de::impls::ArrayInPlaceVisitor<[_; 2]> as serde::de::Visitor>::expecting Unexecuted instantiation: <serde::de::impls::ArrayInPlaceVisitor<[_; 3]> as serde::de::Visitor>::expecting Unexecuted instantiation: <serde::de::impls::ArrayInPlaceVisitor<[_; 4]> as serde::de::Visitor>::expecting Unexecuted instantiation: <serde::de::impls::ArrayInPlaceVisitor<[_; 5]> as serde::de::Visitor>::expecting Unexecuted instantiation: <serde::de::impls::ArrayInPlaceVisitor<[_; 6]> as serde::de::Visitor>::expecting Unexecuted instantiation: <serde::de::impls::ArrayInPlaceVisitor<[_; 7]> as serde::de::Visitor>::expecting Unexecuted instantiation: <serde::de::impls::ArrayInPlaceVisitor<[_; 8]> as serde::de::Visitor>::expecting Unexecuted instantiation: <serde::de::impls::ArrayInPlaceVisitor<[_; 9]> as serde::de::Visitor>::expecting Unexecuted instantiation: <serde::de::impls::ArrayInPlaceVisitor<[_; 10]> as serde::de::Visitor>::expecting Unexecuted instantiation: <serde::de::impls::ArrayInPlaceVisitor<[_; 11]> as serde::de::Visitor>::expecting Unexecuted instantiation: <serde::de::impls::ArrayInPlaceVisitor<[_; 12]> as serde::de::Visitor>::expecting Unexecuted instantiation: <serde::de::impls::ArrayInPlaceVisitor<[_; 13]> as serde::de::Visitor>::expecting Unexecuted instantiation: <serde::de::impls::ArrayInPlaceVisitor<[_; 14]> as serde::de::Visitor>::expecting Unexecuted instantiation: <serde::de::impls::ArrayInPlaceVisitor<[_; 15]> as serde::de::Visitor>::expecting Unexecuted instantiation: <serde::de::impls::ArrayInPlaceVisitor<[_; 16]> as serde::de::Visitor>::expecting Unexecuted instantiation: <serde::de::impls::ArrayInPlaceVisitor<[_; 17]> as serde::de::Visitor>::expecting Unexecuted instantiation: <serde::de::impls::ArrayInPlaceVisitor<[_; 18]> as serde::de::Visitor>::expecting Unexecuted instantiation: <serde::de::impls::ArrayInPlaceVisitor<[_; 19]> as serde::de::Visitor>::expecting Unexecuted instantiation: <serde::de::impls::ArrayInPlaceVisitor<[_; 20]> as serde::de::Visitor>::expecting Unexecuted instantiation: <serde::de::impls::ArrayInPlaceVisitor<[_; 21]> as serde::de::Visitor>::expecting Unexecuted instantiation: <serde::de::impls::ArrayInPlaceVisitor<[_; 22]> as serde::de::Visitor>::expecting Unexecuted instantiation: <serde::de::impls::ArrayInPlaceVisitor<[_; 23]> as serde::de::Visitor>::expecting Unexecuted instantiation: <serde::de::impls::ArrayInPlaceVisitor<[_; 24]> as serde::de::Visitor>::expecting Unexecuted instantiation: <serde::de::impls::ArrayInPlaceVisitor<[_; 25]> as serde::de::Visitor>::expecting Unexecuted instantiation: <serde::de::impls::ArrayInPlaceVisitor<[_; 26]> as serde::de::Visitor>::expecting Unexecuted instantiation: <serde::de::impls::ArrayInPlaceVisitor<[_; 27]> as serde::de::Visitor>::expecting Unexecuted instantiation: <serde::de::impls::ArrayInPlaceVisitor<[_; 28]> as serde::de::Visitor>::expecting Unexecuted instantiation: <serde::de::impls::ArrayInPlaceVisitor<[_; 29]> as serde::de::Visitor>::expecting Unexecuted instantiation: <serde::de::impls::ArrayInPlaceVisitor<[_; 30]> as serde::de::Visitor>::expecting Unexecuted instantiation: <serde::de::impls::ArrayInPlaceVisitor<[_; 31]> as serde::de::Visitor>::expecting Unexecuted instantiation: <serde::de::impls::ArrayInPlaceVisitor<[_; 32]> as serde::de::Visitor>::expecting |
1176 | | |
1177 | | #[inline] |
1178 | 0 | fn visit_seq<A>(self, mut seq: A) -> Result<Self::Value, A::Error> |
1179 | 0 | where |
1180 | 0 | A: SeqAccess<'de>, |
1181 | 0 | { |
1182 | 0 | let mut fail_idx = None; |
1183 | 0 | for (idx, dest) in self.0[..].iter_mut().enumerate() { |
1184 | 0 | if try!(seq.next_element_seed(InPlaceSeed(dest))).is_none() { |
1185 | 0 | fail_idx = Some(idx); |
1186 | 0 | break; |
1187 | 0 | } |
1188 | | } |
1189 | 0 | if let Some(idx) = fail_idx { |
1190 | 0 | return Err(Error::invalid_length(idx, &self)); |
1191 | 0 | } |
1192 | 0 | Ok(()) |
1193 | 0 | } Unexecuted instantiation: <serde::de::impls::ArrayInPlaceVisitor<[_; 1]> as serde::de::Visitor>::visit_seq::<_> Unexecuted instantiation: <serde::de::impls::ArrayInPlaceVisitor<[_; 2]> as serde::de::Visitor>::visit_seq::<_> Unexecuted instantiation: <serde::de::impls::ArrayInPlaceVisitor<[_; 3]> as serde::de::Visitor>::visit_seq::<_> Unexecuted instantiation: <serde::de::impls::ArrayInPlaceVisitor<[_; 4]> as serde::de::Visitor>::visit_seq::<_> Unexecuted instantiation: <serde::de::impls::ArrayInPlaceVisitor<[_; 5]> as serde::de::Visitor>::visit_seq::<_> Unexecuted instantiation: <serde::de::impls::ArrayInPlaceVisitor<[_; 6]> as serde::de::Visitor>::visit_seq::<_> Unexecuted instantiation: <serde::de::impls::ArrayInPlaceVisitor<[_; 7]> as serde::de::Visitor>::visit_seq::<_> Unexecuted instantiation: <serde::de::impls::ArrayInPlaceVisitor<[_; 8]> as serde::de::Visitor>::visit_seq::<_> Unexecuted instantiation: <serde::de::impls::ArrayInPlaceVisitor<[_; 9]> as serde::de::Visitor>::visit_seq::<_> Unexecuted instantiation: <serde::de::impls::ArrayInPlaceVisitor<[_; 10]> as serde::de::Visitor>::visit_seq::<_> Unexecuted instantiation: <serde::de::impls::ArrayInPlaceVisitor<[_; 11]> as serde::de::Visitor>::visit_seq::<_> Unexecuted instantiation: <serde::de::impls::ArrayInPlaceVisitor<[_; 12]> as serde::de::Visitor>::visit_seq::<_> Unexecuted instantiation: <serde::de::impls::ArrayInPlaceVisitor<[_; 13]> as serde::de::Visitor>::visit_seq::<_> Unexecuted instantiation: <serde::de::impls::ArrayInPlaceVisitor<[_; 14]> as serde::de::Visitor>::visit_seq::<_> Unexecuted instantiation: <serde::de::impls::ArrayInPlaceVisitor<[_; 15]> as serde::de::Visitor>::visit_seq::<_> Unexecuted instantiation: <serde::de::impls::ArrayInPlaceVisitor<[_; 16]> as serde::de::Visitor>::visit_seq::<_> Unexecuted instantiation: <serde::de::impls::ArrayInPlaceVisitor<[_; 17]> as serde::de::Visitor>::visit_seq::<_> Unexecuted instantiation: <serde::de::impls::ArrayInPlaceVisitor<[_; 18]> as serde::de::Visitor>::visit_seq::<_> Unexecuted instantiation: <serde::de::impls::ArrayInPlaceVisitor<[_; 19]> as serde::de::Visitor>::visit_seq::<_> Unexecuted instantiation: <serde::de::impls::ArrayInPlaceVisitor<[_; 20]> as serde::de::Visitor>::visit_seq::<_> Unexecuted instantiation: <serde::de::impls::ArrayInPlaceVisitor<[_; 21]> as serde::de::Visitor>::visit_seq::<_> Unexecuted instantiation: <serde::de::impls::ArrayInPlaceVisitor<[_; 22]> as serde::de::Visitor>::visit_seq::<_> Unexecuted instantiation: <serde::de::impls::ArrayInPlaceVisitor<[_; 23]> as serde::de::Visitor>::visit_seq::<_> Unexecuted instantiation: <serde::de::impls::ArrayInPlaceVisitor<[_; 24]> as serde::de::Visitor>::visit_seq::<_> Unexecuted instantiation: <serde::de::impls::ArrayInPlaceVisitor<[_; 25]> as serde::de::Visitor>::visit_seq::<_> Unexecuted instantiation: <serde::de::impls::ArrayInPlaceVisitor<[_; 26]> as serde::de::Visitor>::visit_seq::<_> Unexecuted instantiation: <serde::de::impls::ArrayInPlaceVisitor<[_; 27]> as serde::de::Visitor>::visit_seq::<_> Unexecuted instantiation: <serde::de::impls::ArrayInPlaceVisitor<[_; 28]> as serde::de::Visitor>::visit_seq::<_> Unexecuted instantiation: <serde::de::impls::ArrayInPlaceVisitor<[_; 29]> as serde::de::Visitor>::visit_seq::<_> Unexecuted instantiation: <serde::de::impls::ArrayInPlaceVisitor<[_; 30]> as serde::de::Visitor>::visit_seq::<_> Unexecuted instantiation: <serde::de::impls::ArrayInPlaceVisitor<[_; 31]> as serde::de::Visitor>::visit_seq::<_> Unexecuted instantiation: <serde::de::impls::ArrayInPlaceVisitor<[_; 32]> as serde::de::Visitor>::visit_seq::<_> |
1194 | | } |
1195 | | |
1196 | | impl<'de, T> Deserialize<'de> for [T; $len] |
1197 | | where |
1198 | | T: Deserialize<'de>, |
1199 | | { |
1200 | 0 | fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> |
1201 | 0 | where |
1202 | 0 | D: Deserializer<'de>, |
1203 | 0 | { |
1204 | 0 | deserializer.deserialize_tuple($len, ArrayVisitor::<[T; $len]>::new()) |
1205 | 0 | } Unexecuted instantiation: <[_; 1] as serde::de::Deserialize>::deserialize::<_> Unexecuted instantiation: <[_; 2] as serde::de::Deserialize>::deserialize::<_> Unexecuted instantiation: <[_; 3] as serde::de::Deserialize>::deserialize::<_> Unexecuted instantiation: <[_; 4] as serde::de::Deserialize>::deserialize::<_> Unexecuted instantiation: <[_; 5] as serde::de::Deserialize>::deserialize::<_> Unexecuted instantiation: <[_; 6] as serde::de::Deserialize>::deserialize::<_> Unexecuted instantiation: <[_; 7] as serde::de::Deserialize>::deserialize::<_> Unexecuted instantiation: <[_; 8] as serde::de::Deserialize>::deserialize::<_> Unexecuted instantiation: <[_; 9] as serde::de::Deserialize>::deserialize::<_> Unexecuted instantiation: <[_; 10] as serde::de::Deserialize>::deserialize::<_> Unexecuted instantiation: <[_; 11] as serde::de::Deserialize>::deserialize::<_> Unexecuted instantiation: <[_; 12] as serde::de::Deserialize>::deserialize::<_> Unexecuted instantiation: <[_; 13] as serde::de::Deserialize>::deserialize::<_> Unexecuted instantiation: <[_; 14] as serde::de::Deserialize>::deserialize::<_> Unexecuted instantiation: <[_; 15] as serde::de::Deserialize>::deserialize::<_> Unexecuted instantiation: <[_; 16] as serde::de::Deserialize>::deserialize::<_> Unexecuted instantiation: <[_; 17] as serde::de::Deserialize>::deserialize::<_> Unexecuted instantiation: <[_; 18] as serde::de::Deserialize>::deserialize::<_> Unexecuted instantiation: <[_; 19] as serde::de::Deserialize>::deserialize::<_> Unexecuted instantiation: <[_; 20] as serde::de::Deserialize>::deserialize::<_> Unexecuted instantiation: <[_; 21] as serde::de::Deserialize>::deserialize::<_> Unexecuted instantiation: <[_; 22] as serde::de::Deserialize>::deserialize::<_> Unexecuted instantiation: <[_; 23] as serde::de::Deserialize>::deserialize::<_> Unexecuted instantiation: <[_; 24] as serde::de::Deserialize>::deserialize::<_> Unexecuted instantiation: <[_; 25] as serde::de::Deserialize>::deserialize::<_> Unexecuted instantiation: <[_; 26] as serde::de::Deserialize>::deserialize::<_> Unexecuted instantiation: <[_; 27] as serde::de::Deserialize>::deserialize::<_> Unexecuted instantiation: <[_; 28] as serde::de::Deserialize>::deserialize::<_> Unexecuted instantiation: <[_; 29] as serde::de::Deserialize>::deserialize::<_> Unexecuted instantiation: <[_; 30] as serde::de::Deserialize>::deserialize::<_> Unexecuted instantiation: <[_; 31] as serde::de::Deserialize>::deserialize::<_> Unexecuted instantiation: <[_; 32] as serde::de::Deserialize>::deserialize::<_> |
1206 | | |
1207 | 0 | fn deserialize_in_place<D>(deserializer: D, place: &mut Self) -> Result<(), D::Error> |
1208 | 0 | where |
1209 | 0 | D: Deserializer<'de>, |
1210 | 0 | { |
1211 | 0 | deserializer.deserialize_tuple($len, ArrayInPlaceVisitor(place)) |
1212 | 0 | } Unexecuted instantiation: <[_; 1] as serde::de::Deserialize>::deserialize_in_place::<_> Unexecuted instantiation: <[_; 2] as serde::de::Deserialize>::deserialize_in_place::<_> Unexecuted instantiation: <[_; 3] as serde::de::Deserialize>::deserialize_in_place::<_> Unexecuted instantiation: <[_; 4] as serde::de::Deserialize>::deserialize_in_place::<_> Unexecuted instantiation: <[_; 5] as serde::de::Deserialize>::deserialize_in_place::<_> Unexecuted instantiation: <[_; 6] as serde::de::Deserialize>::deserialize_in_place::<_> Unexecuted instantiation: <[_; 7] as serde::de::Deserialize>::deserialize_in_place::<_> Unexecuted instantiation: <[_; 8] as serde::de::Deserialize>::deserialize_in_place::<_> Unexecuted instantiation: <[_; 9] as serde::de::Deserialize>::deserialize_in_place::<_> Unexecuted instantiation: <[_; 10] as serde::de::Deserialize>::deserialize_in_place::<_> Unexecuted instantiation: <[_; 11] as serde::de::Deserialize>::deserialize_in_place::<_> Unexecuted instantiation: <[_; 12] as serde::de::Deserialize>::deserialize_in_place::<_> Unexecuted instantiation: <[_; 13] as serde::de::Deserialize>::deserialize_in_place::<_> Unexecuted instantiation: <[_; 14] as serde::de::Deserialize>::deserialize_in_place::<_> Unexecuted instantiation: <[_; 15] as serde::de::Deserialize>::deserialize_in_place::<_> Unexecuted instantiation: <[_; 16] as serde::de::Deserialize>::deserialize_in_place::<_> Unexecuted instantiation: <[_; 17] as serde::de::Deserialize>::deserialize_in_place::<_> Unexecuted instantiation: <[_; 18] as serde::de::Deserialize>::deserialize_in_place::<_> Unexecuted instantiation: <[_; 19] as serde::de::Deserialize>::deserialize_in_place::<_> Unexecuted instantiation: <[_; 20] as serde::de::Deserialize>::deserialize_in_place::<_> Unexecuted instantiation: <[_; 21] as serde::de::Deserialize>::deserialize_in_place::<_> Unexecuted instantiation: <[_; 22] as serde::de::Deserialize>::deserialize_in_place::<_> Unexecuted instantiation: <[_; 23] as serde::de::Deserialize>::deserialize_in_place::<_> Unexecuted instantiation: <[_; 24] as serde::de::Deserialize>::deserialize_in_place::<_> Unexecuted instantiation: <[_; 25] as serde::de::Deserialize>::deserialize_in_place::<_> Unexecuted instantiation: <[_; 26] as serde::de::Deserialize>::deserialize_in_place::<_> Unexecuted instantiation: <[_; 27] as serde::de::Deserialize>::deserialize_in_place::<_> Unexecuted instantiation: <[_; 28] as serde::de::Deserialize>::deserialize_in_place::<_> Unexecuted instantiation: <[_; 29] as serde::de::Deserialize>::deserialize_in_place::<_> Unexecuted instantiation: <[_; 30] as serde::de::Deserialize>::deserialize_in_place::<_> Unexecuted instantiation: <[_; 31] as serde::de::Deserialize>::deserialize_in_place::<_> Unexecuted instantiation: <[_; 32] as serde::de::Deserialize>::deserialize_in_place::<_> |
1213 | | } |
1214 | | )+ |
1215 | | } |
1216 | | } |
1217 | | |
1218 | | array_impls! { |
1219 | | 1 => (0) |
1220 | | 2 => (0 1) |
1221 | | 3 => (0 1 2) |
1222 | | 4 => (0 1 2 3) |
1223 | | 5 => (0 1 2 3 4) |
1224 | | 6 => (0 1 2 3 4 5) |
1225 | | 7 => (0 1 2 3 4 5 6) |
1226 | | 8 => (0 1 2 3 4 5 6 7) |
1227 | | 9 => (0 1 2 3 4 5 6 7 8) |
1228 | | 10 => (0 1 2 3 4 5 6 7 8 9) |
1229 | | 11 => (0 1 2 3 4 5 6 7 8 9 10) |
1230 | | 12 => (0 1 2 3 4 5 6 7 8 9 10 11) |
1231 | | 13 => (0 1 2 3 4 5 6 7 8 9 10 11 12) |
1232 | | 14 => (0 1 2 3 4 5 6 7 8 9 10 11 12 13) |
1233 | | 15 => (0 1 2 3 4 5 6 7 8 9 10 11 12 13 14) |
1234 | | 16 => (0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15) |
1235 | | 17 => (0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16) |
1236 | | 18 => (0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17) |
1237 | | 19 => (0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18) |
1238 | | 20 => (0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19) |
1239 | | 21 => (0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20) |
1240 | | 22 => (0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21) |
1241 | | 23 => (0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22) |
1242 | | 24 => (0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23) |
1243 | | 25 => (0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24) |
1244 | | 26 => (0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25) |
1245 | | 27 => (0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26) |
1246 | | 28 => (0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27) |
1247 | | 29 => (0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28) |
1248 | | 30 => (0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29) |
1249 | | 31 => (0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30) |
1250 | | 32 => (0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31) |
1251 | | } |
1252 | | |
1253 | | //////////////////////////////////////////////////////////////////////////////// |
1254 | | |
1255 | | macro_rules! tuple_impls { |
1256 | | ($($len:tt => ($($n:tt $name:ident)+))+) => { |
1257 | | $( |
1258 | | impl<'de, $($name: Deserialize<'de>),+> Deserialize<'de> for ($($name,)+) { |
1259 | | #[inline] |
1260 | 0 | fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> |
1261 | 0 | where |
1262 | 0 | D: Deserializer<'de>, |
1263 | 0 | { |
1264 | | struct TupleVisitor<$($name,)+> { |
1265 | | marker: PhantomData<($($name,)+)>, |
1266 | | } |
1267 | | |
1268 | | impl<'de, $($name: Deserialize<'de>),+> Visitor<'de> for TupleVisitor<$($name,)+> { |
1269 | | type Value = ($($name,)+); |
1270 | | |
1271 | 0 | fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { |
1272 | 0 | formatter.write_str(concat!("a tuple of size ", $len)) |
1273 | 0 | } Unexecuted instantiation: <<(_,) as serde::de::Deserialize>::deserialize::TupleVisitor<_> as serde::de::Visitor>::expecting Unexecuted instantiation: <<(_, _) as serde::de::Deserialize>::deserialize::TupleVisitor<_, _> as serde::de::Visitor>::expecting Unexecuted instantiation: <<(_, _, _) as serde::de::Deserialize>::deserialize::TupleVisitor<_, _, _> as serde::de::Visitor>::expecting Unexecuted instantiation: <<(_, _, _, _) as serde::de::Deserialize>::deserialize::TupleVisitor<_, _, _, _> as serde::de::Visitor>::expecting Unexecuted instantiation: <<(_, _, _, _, _) as serde::de::Deserialize>::deserialize::TupleVisitor<_, _, _, _, _> as serde::de::Visitor>::expecting Unexecuted instantiation: <<(_, _, _, _, _, _) as serde::de::Deserialize>::deserialize::TupleVisitor<_, _, _, _, _, _> as serde::de::Visitor>::expecting Unexecuted instantiation: <<(_, _, _, _, _, _, _) as serde::de::Deserialize>::deserialize::TupleVisitor<_, _, _, _, _, _, _> as serde::de::Visitor>::expecting Unexecuted instantiation: <<(_, _, _, _, _, _, _, _) as serde::de::Deserialize>::deserialize::TupleVisitor<_, _, _, _, _, _, _, _> as serde::de::Visitor>::expecting Unexecuted instantiation: <<(_, _, _, _, _, _, _, _, _) as serde::de::Deserialize>::deserialize::TupleVisitor<_, _, _, _, _, _, _, _, _> as serde::de::Visitor>::expecting Unexecuted instantiation: <<(_, _, _, _, _, _, _, _, _, _) as serde::de::Deserialize>::deserialize::TupleVisitor<_, _, _, _, _, _, _, _, _, _> as serde::de::Visitor>::expecting Unexecuted instantiation: <<(_, _, _, _, _, _, _, _, _, _, _) as serde::de::Deserialize>::deserialize::TupleVisitor<_, _, _, _, _, _, _, _, _, _, _> as serde::de::Visitor>::expecting Unexecuted instantiation: <<(_, _, _, _, _, _, _, _, _, _, _, _) as serde::de::Deserialize>::deserialize::TupleVisitor<_, _, _, _, _, _, _, _, _, _, _, _> as serde::de::Visitor>::expecting Unexecuted instantiation: <<(_, _, _, _, _, _, _, _, _, _, _, _, _) as serde::de::Deserialize>::deserialize::TupleVisitor<_, _, _, _, _, _, _, _, _, _, _, _, _> as serde::de::Visitor>::expecting Unexecuted instantiation: <<(_, _, _, _, _, _, _, _, _, _, _, _, _, _) as serde::de::Deserialize>::deserialize::TupleVisitor<_, _, _, _, _, _, _, _, _, _, _, _, _, _> as serde::de::Visitor>::expecting Unexecuted instantiation: <<(_, _, _, _, _, _, _, _, _, _, _, _, _, _, _) as serde::de::Deserialize>::deserialize::TupleVisitor<_, _, _, _, _, _, _, _, _, _, _, _, _, _, _> as serde::de::Visitor>::expecting Unexecuted instantiation: <<(_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _) as serde::de::Deserialize>::deserialize::TupleVisitor<_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _> as serde::de::Visitor>::expecting |
1274 | | |
1275 | | #[inline] |
1276 | | #[allow(non_snake_case)] |
1277 | 0 | fn visit_seq<A>(self, mut seq: A) -> Result<Self::Value, A::Error> |
1278 | 0 | where |
1279 | 0 | A: SeqAccess<'de>, |
1280 | 0 | { |
1281 | | $( |
1282 | 0 | let $name = match try!(seq.next_element()) { |
1283 | 0 | Some(value) => value, |
1284 | 0 | None => return Err(Error::invalid_length($n, &self)), |
1285 | | }; |
1286 | | )+ |
1287 | | |
1288 | 0 | Ok(($($name,)+)) |
1289 | 0 | } Unexecuted instantiation: <<(_,) as serde::de::Deserialize>::deserialize::TupleVisitor<_> as serde::de::Visitor>::visit_seq::<_> Unexecuted instantiation: <<(_, _) as serde::de::Deserialize>::deserialize::TupleVisitor<_, _> as serde::de::Visitor>::visit_seq::<_> Unexecuted instantiation: <<(_, _, _) as serde::de::Deserialize>::deserialize::TupleVisitor<_, _, _> as serde::de::Visitor>::visit_seq::<_> Unexecuted instantiation: <<(_, _, _, _) as serde::de::Deserialize>::deserialize::TupleVisitor<_, _, _, _> as serde::de::Visitor>::visit_seq::<_> Unexecuted instantiation: <<(_, _, _, _, _) as serde::de::Deserialize>::deserialize::TupleVisitor<_, _, _, _, _> as serde::de::Visitor>::visit_seq::<_> Unexecuted instantiation: <<(_, _, _, _, _, _) as serde::de::Deserialize>::deserialize::TupleVisitor<_, _, _, _, _, _> as serde::de::Visitor>::visit_seq::<_> Unexecuted instantiation: <<(_, _, _, _, _, _, _) as serde::de::Deserialize>::deserialize::TupleVisitor<_, _, _, _, _, _, _> as serde::de::Visitor>::visit_seq::<_> Unexecuted instantiation: <<(_, _, _, _, _, _, _, _) as serde::de::Deserialize>::deserialize::TupleVisitor<_, _, _, _, _, _, _, _> as serde::de::Visitor>::visit_seq::<_> Unexecuted instantiation: <<(_, _, _, _, _, _, _, _, _) as serde::de::Deserialize>::deserialize::TupleVisitor<_, _, _, _, _, _, _, _, _> as serde::de::Visitor>::visit_seq::<_> Unexecuted instantiation: <<(_, _, _, _, _, _, _, _, _, _) as serde::de::Deserialize>::deserialize::TupleVisitor<_, _, _, _, _, _, _, _, _, _> as serde::de::Visitor>::visit_seq::<_> Unexecuted instantiation: <<(_, _, _, _, _, _, _, _, _, _, _) as serde::de::Deserialize>::deserialize::TupleVisitor<_, _, _, _, _, _, _, _, _, _, _> as serde::de::Visitor>::visit_seq::<_> Unexecuted instantiation: <<(_, _, _, _, _, _, _, _, _, _, _, _) as serde::de::Deserialize>::deserialize::TupleVisitor<_, _, _, _, _, _, _, _, _, _, _, _> as serde::de::Visitor>::visit_seq::<_> Unexecuted instantiation: <<(_, _, _, _, _, _, _, _, _, _, _, _, _) as serde::de::Deserialize>::deserialize::TupleVisitor<_, _, _, _, _, _, _, _, _, _, _, _, _> as serde::de::Visitor>::visit_seq::<_> Unexecuted instantiation: <<(_, _, _, _, _, _, _, _, _, _, _, _, _, _) as serde::de::Deserialize>::deserialize::TupleVisitor<_, _, _, _, _, _, _, _, _, _, _, _, _, _> as serde::de::Visitor>::visit_seq::<_> Unexecuted instantiation: <<(_, _, _, _, _, _, _, _, _, _, _, _, _, _, _) as serde::de::Deserialize>::deserialize::TupleVisitor<_, _, _, _, _, _, _, _, _, _, _, _, _, _, _> as serde::de::Visitor>::visit_seq::<_> Unexecuted instantiation: <<(_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _) as serde::de::Deserialize>::deserialize::TupleVisitor<_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _> as serde::de::Visitor>::visit_seq::<_> |
1290 | | } |
1291 | | |
1292 | 0 | deserializer.deserialize_tuple($len, TupleVisitor { marker: PhantomData }) |
1293 | 0 | } Unexecuted instantiation: <(_,) as serde::de::Deserialize>::deserialize::<_> Unexecuted instantiation: <(_, _) as serde::de::Deserialize>::deserialize::<_> Unexecuted instantiation: <(_, _, _) as serde::de::Deserialize>::deserialize::<_> Unexecuted instantiation: <(_, _, _, _) as serde::de::Deserialize>::deserialize::<_> Unexecuted instantiation: <(_, _, _, _, _) as serde::de::Deserialize>::deserialize::<_> Unexecuted instantiation: <(_, _, _, _, _, _) as serde::de::Deserialize>::deserialize::<_> Unexecuted instantiation: <(_, _, _, _, _, _, _) as serde::de::Deserialize>::deserialize::<_> Unexecuted instantiation: <(_, _, _, _, _, _, _, _) as serde::de::Deserialize>::deserialize::<_> Unexecuted instantiation: <(_, _, _, _, _, _, _, _, _) as serde::de::Deserialize>::deserialize::<_> Unexecuted instantiation: <(_, _, _, _, _, _, _, _, _, _) as serde::de::Deserialize>::deserialize::<_> Unexecuted instantiation: <(_, _, _, _, _, _, _, _, _, _, _) as serde::de::Deserialize>::deserialize::<_> Unexecuted instantiation: <(_, _, _, _, _, _, _, _, _, _, _, _) as serde::de::Deserialize>::deserialize::<_> Unexecuted instantiation: <(_, _, _, _, _, _, _, _, _, _, _, _, _) as serde::de::Deserialize>::deserialize::<_> Unexecuted instantiation: <(_, _, _, _, _, _, _, _, _, _, _, _, _, _) as serde::de::Deserialize>::deserialize::<_> Unexecuted instantiation: <(_, _, _, _, _, _, _, _, _, _, _, _, _, _, _) as serde::de::Deserialize>::deserialize::<_> Unexecuted instantiation: <(_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _) as serde::de::Deserialize>::deserialize::<_> |
1294 | | |
1295 | | #[inline] |
1296 | 0 | fn deserialize_in_place<D>(deserializer: D, place: &mut Self) -> Result<(), D::Error> |
1297 | 0 | where |
1298 | 0 | D: Deserializer<'de>, |
1299 | 0 | { |
1300 | | struct TupleInPlaceVisitor<'a, $($name: 'a,)+>(&'a mut ($($name,)+)); |
1301 | | |
1302 | | impl<'a, 'de, $($name: Deserialize<'de>),+> Visitor<'de> for TupleInPlaceVisitor<'a, $($name,)+> { |
1303 | | type Value = (); |
1304 | | |
1305 | 0 | fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { |
1306 | 0 | formatter.write_str(concat!("a tuple of size ", $len)) |
1307 | 0 | } Unexecuted instantiation: <<(_,) as serde::de::Deserialize>::deserialize_in_place::TupleInPlaceVisitor<_> as serde::de::Visitor>::expecting Unexecuted instantiation: <<(_, _) as serde::de::Deserialize>::deserialize_in_place::TupleInPlaceVisitor<_, _> as serde::de::Visitor>::expecting Unexecuted instantiation: <<(_, _, _) as serde::de::Deserialize>::deserialize_in_place::TupleInPlaceVisitor<_, _, _> as serde::de::Visitor>::expecting Unexecuted instantiation: <<(_, _, _, _) as serde::de::Deserialize>::deserialize_in_place::TupleInPlaceVisitor<_, _, _, _> as serde::de::Visitor>::expecting Unexecuted instantiation: <<(_, _, _, _, _) as serde::de::Deserialize>::deserialize_in_place::TupleInPlaceVisitor<_, _, _, _, _> as serde::de::Visitor>::expecting Unexecuted instantiation: <<(_, _, _, _, _, _) as serde::de::Deserialize>::deserialize_in_place::TupleInPlaceVisitor<_, _, _, _, _, _> as serde::de::Visitor>::expecting Unexecuted instantiation: <<(_, _, _, _, _, _, _) as serde::de::Deserialize>::deserialize_in_place::TupleInPlaceVisitor<_, _, _, _, _, _, _> as serde::de::Visitor>::expecting Unexecuted instantiation: <<(_, _, _, _, _, _, _, _) as serde::de::Deserialize>::deserialize_in_place::TupleInPlaceVisitor<_, _, _, _, _, _, _, _> as serde::de::Visitor>::expecting Unexecuted instantiation: <<(_, _, _, _, _, _, _, _, _) as serde::de::Deserialize>::deserialize_in_place::TupleInPlaceVisitor<_, _, _, _, _, _, _, _, _> as serde::de::Visitor>::expecting Unexecuted instantiation: <<(_, _, _, _, _, _, _, _, _, _) as serde::de::Deserialize>::deserialize_in_place::TupleInPlaceVisitor<_, _, _, _, _, _, _, _, _, _> as serde::de::Visitor>::expecting Unexecuted instantiation: <<(_, _, _, _, _, _, _, _, _, _, _) as serde::de::Deserialize>::deserialize_in_place::TupleInPlaceVisitor<_, _, _, _, _, _, _, _, _, _, _> as serde::de::Visitor>::expecting Unexecuted instantiation: <<(_, _, _, _, _, _, _, _, _, _, _, _) as serde::de::Deserialize>::deserialize_in_place::TupleInPlaceVisitor<_, _, _, _, _, _, _, _, _, _, _, _> as serde::de::Visitor>::expecting Unexecuted instantiation: <<(_, _, _, _, _, _, _, _, _, _, _, _, _) as serde::de::Deserialize>::deserialize_in_place::TupleInPlaceVisitor<_, _, _, _, _, _, _, _, _, _, _, _, _> as serde::de::Visitor>::expecting Unexecuted instantiation: <<(_, _, _, _, _, _, _, _, _, _, _, _, _, _) as serde::de::Deserialize>::deserialize_in_place::TupleInPlaceVisitor<_, _, _, _, _, _, _, _, _, _, _, _, _, _> as serde::de::Visitor>::expecting Unexecuted instantiation: <<(_, _, _, _, _, _, _, _, _, _, _, _, _, _, _) as serde::de::Deserialize>::deserialize_in_place::TupleInPlaceVisitor<_, _, _, _, _, _, _, _, _, _, _, _, _, _, _> as serde::de::Visitor>::expecting Unexecuted instantiation: <<(_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _) as serde::de::Deserialize>::deserialize_in_place::TupleInPlaceVisitor<_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _> as serde::de::Visitor>::expecting |
1308 | | |
1309 | | #[inline] |
1310 | | #[allow(non_snake_case)] |
1311 | 0 | fn visit_seq<A>(self, mut seq: A) -> Result<Self::Value, A::Error> |
1312 | 0 | where |
1313 | 0 | A: SeqAccess<'de>, |
1314 | 0 | { |
1315 | | $( |
1316 | 0 | if try!(seq.next_element_seed(InPlaceSeed(&mut (self.0).$n))).is_none() { |
1317 | 0 | return Err(Error::invalid_length($n, &self)); |
1318 | 0 | } |
1319 | 0 | )+ |
1320 | 0 |
|
1321 | 0 | Ok(()) |
1322 | 0 | } Unexecuted instantiation: <<(_,) as serde::de::Deserialize>::deserialize_in_place::TupleInPlaceVisitor<_> as serde::de::Visitor>::visit_seq::<_> Unexecuted instantiation: <<(_, _) as serde::de::Deserialize>::deserialize_in_place::TupleInPlaceVisitor<_, _> as serde::de::Visitor>::visit_seq::<_> Unexecuted instantiation: <<(_, _, _) as serde::de::Deserialize>::deserialize_in_place::TupleInPlaceVisitor<_, _, _> as serde::de::Visitor>::visit_seq::<_> Unexecuted instantiation: <<(_, _, _, _) as serde::de::Deserialize>::deserialize_in_place::TupleInPlaceVisitor<_, _, _, _> as serde::de::Visitor>::visit_seq::<_> Unexecuted instantiation: <<(_, _, _, _, _) as serde::de::Deserialize>::deserialize_in_place::TupleInPlaceVisitor<_, _, _, _, _> as serde::de::Visitor>::visit_seq::<_> Unexecuted instantiation: <<(_, _, _, _, _, _) as serde::de::Deserialize>::deserialize_in_place::TupleInPlaceVisitor<_, _, _, _, _, _> as serde::de::Visitor>::visit_seq::<_> Unexecuted instantiation: <<(_, _, _, _, _, _, _) as serde::de::Deserialize>::deserialize_in_place::TupleInPlaceVisitor<_, _, _, _, _, _, _> as serde::de::Visitor>::visit_seq::<_> Unexecuted instantiation: <<(_, _, _, _, _, _, _, _) as serde::de::Deserialize>::deserialize_in_place::TupleInPlaceVisitor<_, _, _, _, _, _, _, _> as serde::de::Visitor>::visit_seq::<_> Unexecuted instantiation: <<(_, _, _, _, _, _, _, _, _) as serde::de::Deserialize>::deserialize_in_place::TupleInPlaceVisitor<_, _, _, _, _, _, _, _, _> as serde::de::Visitor>::visit_seq::<_> Unexecuted instantiation: <<(_, _, _, _, _, _, _, _, _, _) as serde::de::Deserialize>::deserialize_in_place::TupleInPlaceVisitor<_, _, _, _, _, _, _, _, _, _> as serde::de::Visitor>::visit_seq::<_> Unexecuted instantiation: <<(_, _, _, _, _, _, _, _, _, _, _) as serde::de::Deserialize>::deserialize_in_place::TupleInPlaceVisitor<_, _, _, _, _, _, _, _, _, _, _> as serde::de::Visitor>::visit_seq::<_> Unexecuted instantiation: <<(_, _, _, _, _, _, _, _, _, _, _, _) as serde::de::Deserialize>::deserialize_in_place::TupleInPlaceVisitor<_, _, _, _, _, _, _, _, _, _, _, _> as serde::de::Visitor>::visit_seq::<_> Unexecuted instantiation: <<(_, _, _, _, _, _, _, _, _, _, _, _, _) as serde::de::Deserialize>::deserialize_in_place::TupleInPlaceVisitor<_, _, _, _, _, _, _, _, _, _, _, _, _> as serde::de::Visitor>::visit_seq::<_> Unexecuted instantiation: <<(_, _, _, _, _, _, _, _, _, _, _, _, _, _) as serde::de::Deserialize>::deserialize_in_place::TupleInPlaceVisitor<_, _, _, _, _, _, _, _, _, _, _, _, _, _> as serde::de::Visitor>::visit_seq::<_> Unexecuted instantiation: <<(_, _, _, _, _, _, _, _, _, _, _, _, _, _, _) as serde::de::Deserialize>::deserialize_in_place::TupleInPlaceVisitor<_, _, _, _, _, _, _, _, _, _, _, _, _, _, _> as serde::de::Visitor>::visit_seq::<_> Unexecuted instantiation: <<(_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _) as serde::de::Deserialize>::deserialize_in_place::TupleInPlaceVisitor<_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _> as serde::de::Visitor>::visit_seq::<_> |
1323 | | } |
1324 | | |
1325 | 0 | deserializer.deserialize_tuple($len, TupleInPlaceVisitor(place)) |
1326 | 0 | } Unexecuted instantiation: <(_,) as serde::de::Deserialize>::deserialize_in_place::<_> Unexecuted instantiation: <(_, _) as serde::de::Deserialize>::deserialize_in_place::<_> Unexecuted instantiation: <(_, _, _) as serde::de::Deserialize>::deserialize_in_place::<_> Unexecuted instantiation: <(_, _, _, _) as serde::de::Deserialize>::deserialize_in_place::<_> Unexecuted instantiation: <(_, _, _, _, _) as serde::de::Deserialize>::deserialize_in_place::<_> Unexecuted instantiation: <(_, _, _, _, _, _) as serde::de::Deserialize>::deserialize_in_place::<_> Unexecuted instantiation: <(_, _, _, _, _, _, _) as serde::de::Deserialize>::deserialize_in_place::<_> Unexecuted instantiation: <(_, _, _, _, _, _, _, _) as serde::de::Deserialize>::deserialize_in_place::<_> Unexecuted instantiation: <(_, _, _, _, _, _, _, _, _) as serde::de::Deserialize>::deserialize_in_place::<_> Unexecuted instantiation: <(_, _, _, _, _, _, _, _, _, _) as serde::de::Deserialize>::deserialize_in_place::<_> Unexecuted instantiation: <(_, _, _, _, _, _, _, _, _, _, _) as serde::de::Deserialize>::deserialize_in_place::<_> Unexecuted instantiation: <(_, _, _, _, _, _, _, _, _, _, _, _) as serde::de::Deserialize>::deserialize_in_place::<_> Unexecuted instantiation: <(_, _, _, _, _, _, _, _, _, _, _, _, _) as serde::de::Deserialize>::deserialize_in_place::<_> Unexecuted instantiation: <(_, _, _, _, _, _, _, _, _, _, _, _, _, _) as serde::de::Deserialize>::deserialize_in_place::<_> Unexecuted instantiation: <(_, _, _, _, _, _, _, _, _, _, _, _, _, _, _) as serde::de::Deserialize>::deserialize_in_place::<_> Unexecuted instantiation: <(_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _) as serde::de::Deserialize>::deserialize_in_place::<_> |
1327 | | } |
1328 | | )+ |
1329 | | } |
1330 | | } |
1331 | | |
1332 | | tuple_impls! { |
1333 | | 1 => (0 T0) |
1334 | | 2 => (0 T0 1 T1) |
1335 | | 3 => (0 T0 1 T1 2 T2) |
1336 | | 4 => (0 T0 1 T1 2 T2 3 T3) |
1337 | | 5 => (0 T0 1 T1 2 T2 3 T3 4 T4) |
1338 | | 6 => (0 T0 1 T1 2 T2 3 T3 4 T4 5 T5) |
1339 | | 7 => (0 T0 1 T1 2 T2 3 T3 4 T4 5 T5 6 T6) |
1340 | | 8 => (0 T0 1 T1 2 T2 3 T3 4 T4 5 T5 6 T6 7 T7) |
1341 | | 9 => (0 T0 1 T1 2 T2 3 T3 4 T4 5 T5 6 T6 7 T7 8 T8) |
1342 | | 10 => (0 T0 1 T1 2 T2 3 T3 4 T4 5 T5 6 T6 7 T7 8 T8 9 T9) |
1343 | | 11 => (0 T0 1 T1 2 T2 3 T3 4 T4 5 T5 6 T6 7 T7 8 T8 9 T9 10 T10) |
1344 | | 12 => (0 T0 1 T1 2 T2 3 T3 4 T4 5 T5 6 T6 7 T7 8 T8 9 T9 10 T10 11 T11) |
1345 | | 13 => (0 T0 1 T1 2 T2 3 T3 4 T4 5 T5 6 T6 7 T7 8 T8 9 T9 10 T10 11 T11 12 T12) |
1346 | | 14 => (0 T0 1 T1 2 T2 3 T3 4 T4 5 T5 6 T6 7 T7 8 T8 9 T9 10 T10 11 T11 12 T12 13 T13) |
1347 | | 15 => (0 T0 1 T1 2 T2 3 T3 4 T4 5 T5 6 T6 7 T7 8 T8 9 T9 10 T10 11 T11 12 T12 13 T13 14 T14) |
1348 | | 16 => (0 T0 1 T1 2 T2 3 T3 4 T4 5 T5 6 T6 7 T7 8 T8 9 T9 10 T10 11 T11 12 T12 13 T13 14 T14 15 T15) |
1349 | | } |
1350 | | |
1351 | | //////////////////////////////////////////////////////////////////////////////// |
1352 | | |
1353 | | #[cfg(any(feature = "std", feature = "alloc"))] |
1354 | | macro_rules! map_impl { |
1355 | | ( |
1356 | | $ty:ident <K $(: $kbound1:ident $(+ $kbound2:ident)*)*, V $(, $typaram:ident : $bound1:ident $(+ $bound2:ident)*)*>, |
1357 | | $access:ident, |
1358 | | $with_capacity:expr |
1359 | | ) => { |
1360 | | impl<'de, K, V $(, $typaram)*> Deserialize<'de> for $ty<K, V $(, $typaram)*> |
1361 | | where |
1362 | | K: Deserialize<'de> $(+ $kbound1 $(+ $kbound2)*)*, |
1363 | | V: Deserialize<'de>, |
1364 | | $($typaram: $bound1 $(+ $bound2)*),* |
1365 | | { |
1366 | 0 | fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> |
1367 | 0 | where |
1368 | 0 | D: Deserializer<'de>, |
1369 | 0 | { |
1370 | | struct MapVisitor<K, V $(, $typaram)*> { |
1371 | | marker: PhantomData<$ty<K, V $(, $typaram)*>>, |
1372 | | } |
1373 | | |
1374 | | impl<'de, K, V $(, $typaram)*> Visitor<'de> for MapVisitor<K, V $(, $typaram)*> |
1375 | | where |
1376 | | K: Deserialize<'de> $(+ $kbound1 $(+ $kbound2)*)*, |
1377 | | V: Deserialize<'de>, |
1378 | | $($typaram: $bound1 $(+ $bound2)*),* |
1379 | | { |
1380 | | type Value = $ty<K, V $(, $typaram)*>; |
1381 | | |
1382 | 0 | fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { |
1383 | 0 | formatter.write_str("a map") |
1384 | 0 | } Unexecuted instantiation: <<alloc::collections::btree::map::BTreeMap<_, _> as serde::de::Deserialize>::deserialize::MapVisitor<_, _> as serde::de::Visitor>::expecting Unexecuted instantiation: <<std::collections::hash::map::HashMap<_, _, _> as serde::de::Deserialize>::deserialize::MapVisitor<_, _, _> as serde::de::Visitor>::expecting |
1385 | | |
1386 | | #[inline] |
1387 | 0 | fn visit_map<A>(self, mut $access: A) -> Result<Self::Value, A::Error> |
1388 | 0 | where |
1389 | 0 | A: MapAccess<'de>, |
1390 | 0 | { |
1391 | 0 | let mut values = $with_capacity; |
1392 | | |
1393 | 0 | while let Some((key, value)) = try!($access.next_entry()) { |
1394 | 0 | values.insert(key, value); |
1395 | 0 | } |
1396 | | |
1397 | 0 | Ok(values) |
1398 | 0 | } Unexecuted instantiation: <<alloc::collections::btree::map::BTreeMap<_, _> as serde::de::Deserialize>::deserialize::MapVisitor<_, _> as serde::de::Visitor>::visit_map::<_> Unexecuted instantiation: <<std::collections::hash::map::HashMap<_, _, _> as serde::de::Deserialize>::deserialize::MapVisitor<_, _, _> as serde::de::Visitor>::visit_map::<_> |
1399 | | } |
1400 | | |
1401 | 0 | let visitor = MapVisitor { marker: PhantomData }; |
1402 | 0 | deserializer.deserialize_map(visitor) |
1403 | 0 | } Unexecuted instantiation: <alloc::collections::btree::map::BTreeMap<_, _> as serde::de::Deserialize>::deserialize::<_> Unexecuted instantiation: <std::collections::hash::map::HashMap<_, _, _> as serde::de::Deserialize>::deserialize::<_> |
1404 | | } |
1405 | | } |
1406 | | } |
1407 | | |
1408 | | #[cfg(any(feature = "std", feature = "alloc"))] |
1409 | | map_impl!( |
1410 | | BTreeMap<K: Ord, V>, |
1411 | | map, |
1412 | | BTreeMap::new()); |
1413 | | |
1414 | | #[cfg(feature = "std")] |
1415 | | map_impl!( |
1416 | | HashMap<K: Eq + Hash, V, S: BuildHasher + Default>, |
1417 | | map, |
1418 | | HashMap::with_capacity_and_hasher(size_hint::cautious(map.size_hint()), S::default())); |
1419 | | |
1420 | | //////////////////////////////////////////////////////////////////////////////// |
1421 | | |
1422 | | #[cfg(feature = "std")] |
1423 | | macro_rules! parse_ip_impl { |
1424 | | ($expecting:tt $ty:ty; $size:tt) => { |
1425 | | impl<'de> Deserialize<'de> for $ty { |
1426 | 0 | fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> |
1427 | 0 | where |
1428 | 0 | D: Deserializer<'de>, |
1429 | 0 | { |
1430 | 0 | if deserializer.is_human_readable() { |
1431 | 0 | deserializer.deserialize_str(FromStrVisitor::new($expecting)) |
1432 | | } else { |
1433 | 0 | <[u8; $size]>::deserialize(deserializer).map(<$ty>::from) |
1434 | | } |
1435 | 0 | } Unexecuted instantiation: <core::net::ip_addr::Ipv4Addr as serde::de::Deserialize>::deserialize::<_> Unexecuted instantiation: <core::net::ip_addr::Ipv6Addr as serde::de::Deserialize>::deserialize::<_> |
1436 | | } |
1437 | | }; |
1438 | | } |
1439 | | |
1440 | | #[cfg(feature = "std")] |
1441 | | macro_rules! variant_identifier { |
1442 | | ( |
1443 | | $name_kind:ident ($($variant:ident; $bytes:expr; $index:expr),*) |
1444 | | $expecting_message:expr, |
1445 | | $variants_name:ident |
1446 | | ) => { |
1447 | | enum $name_kind { |
1448 | | $($variant),* |
1449 | | } |
1450 | | |
1451 | | static $variants_name: &'static [&'static str] = &[$(stringify!($variant)),*]; |
1452 | | |
1453 | | impl<'de> Deserialize<'de> for $name_kind { |
1454 | 0 | fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> |
1455 | 0 | where |
1456 | 0 | D: Deserializer<'de>, |
1457 | 0 | { |
1458 | | struct KindVisitor; |
1459 | | |
1460 | | impl<'de> Visitor<'de> for KindVisitor { |
1461 | | type Value = $name_kind; |
1462 | | |
1463 | 0 | fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { |
1464 | 0 | formatter.write_str($expecting_message) |
1465 | 0 | } Unexecuted instantiation: <<<core::net::ip_addr::IpAddr as serde::de::Deserialize>::deserialize::IpAddrKind as serde::de::Deserialize>::deserialize::KindVisitor as serde::de::Visitor>::expecting Unexecuted instantiation: <<<core::net::socket_addr::SocketAddr as serde::de::Deserialize>::deserialize::SocketAddrKind as serde::de::Deserialize>::deserialize::KindVisitor as serde::de::Visitor>::expecting Unexecuted instantiation: <<serde::de::impls::OsStringKind as serde::de::Deserialize>::deserialize::KindVisitor as serde::de::Visitor>::expecting |
1466 | | |
1467 | 0 | fn visit_u64<E>(self, value: u64) -> Result<Self::Value, E> |
1468 | 0 | where |
1469 | 0 | E: Error, |
1470 | 0 | { |
1471 | 0 | match value { |
1472 | | $( |
1473 | 0 | $index => Ok($name_kind :: $variant), |
1474 | | )* |
1475 | 0 | _ => Err(Error::invalid_value(Unexpected::Unsigned(value), &self),), |
1476 | | } |
1477 | 0 | } Unexecuted instantiation: <<<core::net::ip_addr::IpAddr as serde::de::Deserialize>::deserialize::IpAddrKind as serde::de::Deserialize>::deserialize::KindVisitor as serde::de::Visitor>::visit_u64::<_> Unexecuted instantiation: <<<core::net::socket_addr::SocketAddr as serde::de::Deserialize>::deserialize::SocketAddrKind as serde::de::Deserialize>::deserialize::KindVisitor as serde::de::Visitor>::visit_u64::<_> Unexecuted instantiation: <<serde::de::impls::OsStringKind as serde::de::Deserialize>::deserialize::KindVisitor as serde::de::Visitor>::visit_u64::<_> |
1478 | | |
1479 | 0 | fn visit_str<E>(self, value: &str) -> Result<Self::Value, E> |
1480 | 0 | where |
1481 | 0 | E: Error, |
1482 | 0 | { |
1483 | 0 | match value { |
1484 | 0 | $( |
1485 | 0 | stringify!($variant) => Ok($name_kind :: $variant), |
1486 | | )* |
1487 | 0 | _ => Err(Error::unknown_variant(value, $variants_name)), |
1488 | | } |
1489 | 0 | } Unexecuted instantiation: <<<core::net::ip_addr::IpAddr as serde::de::Deserialize>::deserialize::IpAddrKind as serde::de::Deserialize>::deserialize::KindVisitor as serde::de::Visitor>::visit_str::<_> Unexecuted instantiation: <<<core::net::socket_addr::SocketAddr as serde::de::Deserialize>::deserialize::SocketAddrKind as serde::de::Deserialize>::deserialize::KindVisitor as serde::de::Visitor>::visit_str::<_> Unexecuted instantiation: <<serde::de::impls::OsStringKind as serde::de::Deserialize>::deserialize::KindVisitor as serde::de::Visitor>::visit_str::<_> |
1490 | | |
1491 | 0 | fn visit_bytes<E>(self, value: &[u8]) -> Result<Self::Value, E> |
1492 | 0 | where |
1493 | 0 | E: Error, |
1494 | 0 | { |
1495 | 0 | match value { |
1496 | | $( |
1497 | 0 | $bytes => Ok($name_kind :: $variant), |
1498 | | )* |
1499 | | _ => { |
1500 | 0 | match str::from_utf8(value) { |
1501 | 0 | Ok(value) => Err(Error::unknown_variant(value, $variants_name)), |
1502 | 0 | Err(_) => Err(Error::invalid_value(Unexpected::Bytes(value), &self)), |
1503 | | } |
1504 | | } |
1505 | | } |
1506 | 0 | } Unexecuted instantiation: <<<core::net::ip_addr::IpAddr as serde::de::Deserialize>::deserialize::IpAddrKind as serde::de::Deserialize>::deserialize::KindVisitor as serde::de::Visitor>::visit_bytes::<_> Unexecuted instantiation: <<<core::net::socket_addr::SocketAddr as serde::de::Deserialize>::deserialize::SocketAddrKind as serde::de::Deserialize>::deserialize::KindVisitor as serde::de::Visitor>::visit_bytes::<_> Unexecuted instantiation: <<serde::de::impls::OsStringKind as serde::de::Deserialize>::deserialize::KindVisitor as serde::de::Visitor>::visit_bytes::<_> |
1507 | | } |
1508 | | |
1509 | 0 | deserializer.deserialize_identifier(KindVisitor) |
1510 | 0 | } Unexecuted instantiation: <<core::net::ip_addr::IpAddr as serde::de::Deserialize>::deserialize::IpAddrKind as serde::de::Deserialize>::deserialize::<_> Unexecuted instantiation: <<core::net::socket_addr::SocketAddr as serde::de::Deserialize>::deserialize::SocketAddrKind as serde::de::Deserialize>::deserialize::<_> Unexecuted instantiation: <serde::de::impls::OsStringKind as serde::de::Deserialize>::deserialize::<_> |
1511 | | } |
1512 | | } |
1513 | | } |
1514 | | |
1515 | | #[cfg(feature = "std")] |
1516 | | macro_rules! deserialize_enum { |
1517 | | ( |
1518 | | $name:ident $name_kind:ident ($($variant:ident; $bytes:expr; $index:expr),*) |
1519 | | $expecting_message:expr, |
1520 | | $deserializer:expr |
1521 | | ) => { |
1522 | | variant_identifier! { |
1523 | | $name_kind ($($variant; $bytes; $index),*) |
1524 | | $expecting_message, |
1525 | | VARIANTS |
1526 | | } |
1527 | | |
1528 | | struct EnumVisitor; |
1529 | | impl<'de> Visitor<'de> for EnumVisitor { |
1530 | | type Value = $name; |
1531 | | |
1532 | 0 | fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { |
1533 | 0 | formatter.write_str(concat!("a ", stringify!($name))) |
1534 | 0 | } Unexecuted instantiation: <<core::net::ip_addr::IpAddr as serde::de::Deserialize>::deserialize::EnumVisitor as serde::de::Visitor>::expecting Unexecuted instantiation: <<core::net::socket_addr::SocketAddr as serde::de::Deserialize>::deserialize::EnumVisitor as serde::de::Visitor>::expecting |
1535 | | |
1536 | | |
1537 | 0 | fn visit_enum<A>(self, data: A) -> Result<Self::Value, A::Error> |
1538 | 0 | where |
1539 | 0 | A: EnumAccess<'de>, |
1540 | 0 | { |
1541 | 0 | match try!(data.variant()) { |
1542 | | $( |
1543 | 0 | ($name_kind :: $variant, v) => v.newtype_variant().map($name :: $variant), |
1544 | | )* |
1545 | | } |
1546 | 0 | } Unexecuted instantiation: <<core::net::ip_addr::IpAddr as serde::de::Deserialize>::deserialize::EnumVisitor as serde::de::Visitor>::visit_enum::<_> Unexecuted instantiation: <<core::net::socket_addr::SocketAddr as serde::de::Deserialize>::deserialize::EnumVisitor as serde::de::Visitor>::visit_enum::<_> |
1547 | | } |
1548 | | $deserializer.deserialize_enum(stringify!($name), VARIANTS, EnumVisitor) |
1549 | | } |
1550 | | } |
1551 | | |
1552 | | #[cfg(feature = "std")] |
1553 | | impl<'de> Deserialize<'de> for net::IpAddr { |
1554 | 0 | fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> |
1555 | 0 | where |
1556 | 0 | D: Deserializer<'de>, |
1557 | 0 | { |
1558 | 0 | if deserializer.is_human_readable() { |
1559 | 0 | deserializer.deserialize_str(FromStrVisitor::new("IP address")) |
1560 | | } else { |
1561 | | use lib::net::IpAddr; |
1562 | 0 | deserialize_enum! { |
1563 | 0 | IpAddr IpAddrKind (V4; b"V4"; 0, V6; b"V6"; 1) |
1564 | 0 | "`V4` or `V6`", |
1565 | 0 | deserializer |
1566 | 0 | } |
1567 | | } |
1568 | 0 | } |
1569 | | } |
1570 | | |
1571 | | #[cfg(feature = "std")] |
1572 | | parse_ip_impl!("IPv4 address" net::Ipv4Addr; 4); |
1573 | | |
1574 | | #[cfg(feature = "std")] |
1575 | | parse_ip_impl!("IPv6 address" net::Ipv6Addr; 16); |
1576 | | |
1577 | | #[cfg(feature = "std")] |
1578 | | macro_rules! parse_socket_impl { |
1579 | | ($expecting:tt $ty:ty, $new:expr) => { |
1580 | | impl<'de> Deserialize<'de> for $ty { |
1581 | 0 | fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> |
1582 | 0 | where |
1583 | 0 | D: Deserializer<'de>, |
1584 | 0 | { |
1585 | 0 | if deserializer.is_human_readable() { |
1586 | 0 | deserializer.deserialize_str(FromStrVisitor::new($expecting)) |
1587 | | } else { |
1588 | 0 | <(_, u16)>::deserialize(deserializer).map(|(ip, port)| $new(ip, port)) Unexecuted instantiation: <core::net::socket_addr::SocketAddrV4 as serde::de::Deserialize>::deserialize::<_>::{closure#0} Unexecuted instantiation: <core::net::socket_addr::SocketAddrV6 as serde::de::Deserialize>::deserialize::<_>::{closure#0} |
1589 | | } |
1590 | 0 | } Unexecuted instantiation: <core::net::socket_addr::SocketAddrV4 as serde::de::Deserialize>::deserialize::<_> Unexecuted instantiation: <core::net::socket_addr::SocketAddrV6 as serde::de::Deserialize>::deserialize::<_> |
1591 | | } |
1592 | | }; |
1593 | | } |
1594 | | |
1595 | | #[cfg(feature = "std")] |
1596 | | impl<'de> Deserialize<'de> for net::SocketAddr { |
1597 | 0 | fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> |
1598 | 0 | where |
1599 | 0 | D: Deserializer<'de>, |
1600 | 0 | { |
1601 | 0 | if deserializer.is_human_readable() { |
1602 | 0 | deserializer.deserialize_str(FromStrVisitor::new("socket address")) |
1603 | | } else { |
1604 | | use lib::net::SocketAddr; |
1605 | 0 | deserialize_enum! { |
1606 | 0 | SocketAddr SocketAddrKind (V4; b"V4"; 0, V6; b"V6"; 1) |
1607 | 0 | "`V4` or `V6`", |
1608 | 0 | deserializer |
1609 | 0 | } |
1610 | | } |
1611 | 0 | } |
1612 | | } |
1613 | | |
1614 | | #[cfg(feature = "std")] |
1615 | | parse_socket_impl!("IPv4 socket address" net::SocketAddrV4, net::SocketAddrV4::new); |
1616 | | |
1617 | | #[cfg(feature = "std")] |
1618 | 0 | parse_socket_impl!("IPv6 socket address" net::SocketAddrV6, |ip, port| net::SocketAddrV6::new( |
1619 | 0 | ip, port, 0, 0 |
1620 | 0 | )); |
1621 | | |
1622 | | //////////////////////////////////////////////////////////////////////////////// |
1623 | | |
1624 | | #[cfg(feature = "std")] |
1625 | | struct PathVisitor; |
1626 | | |
1627 | | #[cfg(feature = "std")] |
1628 | | impl<'a> Visitor<'a> for PathVisitor { |
1629 | | type Value = &'a Path; |
1630 | | |
1631 | 0 | fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { |
1632 | 0 | formatter.write_str("a borrowed path") |
1633 | 0 | } |
1634 | | |
1635 | 0 | fn visit_borrowed_str<E>(self, v: &'a str) -> Result<Self::Value, E> |
1636 | 0 | where |
1637 | 0 | E: Error, |
1638 | 0 | { |
1639 | 0 | Ok(v.as_ref()) |
1640 | 0 | } |
1641 | | |
1642 | 0 | fn visit_borrowed_bytes<E>(self, v: &'a [u8]) -> Result<Self::Value, E> |
1643 | 0 | where |
1644 | 0 | E: Error, |
1645 | 0 | { |
1646 | 0 | str::from_utf8(v) |
1647 | 0 | .map(AsRef::as_ref) |
1648 | 0 | .map_err(|_| Error::invalid_value(Unexpected::Bytes(v), &self)) |
1649 | 0 | } |
1650 | | } |
1651 | | |
1652 | | #[cfg(feature = "std")] |
1653 | | impl<'de: 'a, 'a> Deserialize<'de> for &'a Path { |
1654 | 0 | fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> |
1655 | 0 | where |
1656 | 0 | D: Deserializer<'de>, |
1657 | 0 | { |
1658 | 0 | deserializer.deserialize_str(PathVisitor) |
1659 | 0 | } |
1660 | | } |
1661 | | |
1662 | | #[cfg(feature = "std")] |
1663 | | struct PathBufVisitor; |
1664 | | |
1665 | | #[cfg(feature = "std")] |
1666 | | impl<'de> Visitor<'de> for PathBufVisitor { |
1667 | | type Value = PathBuf; |
1668 | | |
1669 | 0 | fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { |
1670 | 0 | formatter.write_str("path string") |
1671 | 0 | } |
1672 | | |
1673 | 0 | fn visit_str<E>(self, v: &str) -> Result<Self::Value, E> |
1674 | 0 | where |
1675 | 0 | E: Error, |
1676 | 0 | { |
1677 | 0 | Ok(From::from(v)) |
1678 | 0 | } Unexecuted instantiation: <serde::de::impls::PathBufVisitor as serde::de::Visitor>::visit_str::<serde_json::error::Error> Unexecuted instantiation: <serde::de::impls::PathBufVisitor as serde::de::Visitor>::visit_str::<_> |
1679 | | |
1680 | 0 | fn visit_string<E>(self, v: String) -> Result<Self::Value, E> |
1681 | 0 | where |
1682 | 0 | E: Error, |
1683 | 0 | { |
1684 | 0 | Ok(From::from(v)) |
1685 | 0 | } |
1686 | | |
1687 | 0 | fn visit_bytes<E>(self, v: &[u8]) -> Result<Self::Value, E> |
1688 | 0 | where |
1689 | 0 | E: Error, |
1690 | 0 | { |
1691 | 0 | str::from_utf8(v) |
1692 | 0 | .map(From::from) |
1693 | 0 | .map_err(|_| Error::invalid_value(Unexpected::Bytes(v), &self)) |
1694 | 0 | } |
1695 | | |
1696 | 0 | fn visit_byte_buf<E>(self, v: Vec<u8>) -> Result<Self::Value, E> |
1697 | 0 | where |
1698 | 0 | E: Error, |
1699 | 0 | { |
1700 | 0 | String::from_utf8(v) |
1701 | 0 | .map(From::from) |
1702 | 0 | .map_err(|e| Error::invalid_value(Unexpected::Bytes(&e.into_bytes()), &self)) |
1703 | 0 | } |
1704 | | } |
1705 | | |
1706 | | #[cfg(feature = "std")] |
1707 | | impl<'de> Deserialize<'de> for PathBuf { |
1708 | 0 | fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> |
1709 | 0 | where |
1710 | 0 | D: Deserializer<'de>, |
1711 | 0 | { |
1712 | 0 | deserializer.deserialize_string(PathBufVisitor) |
1713 | 0 | } Unexecuted instantiation: <std::path::PathBuf as serde::de::Deserialize>::deserialize::<serde::__private::de::missing_field::MissingFieldDeserializer<serde_json::error::Error>> Unexecuted instantiation: <std::path::PathBuf as serde::de::Deserialize>::deserialize::<&mut serde_json::de::Deserializer<serde_json::read::SliceRead>> Unexecuted instantiation: <std::path::PathBuf as serde::de::Deserialize>::deserialize::<_> |
1714 | | } |
1715 | | |
1716 | | #[cfg(all(feature = "std", not(no_de_boxed_path)))] |
1717 | | forwarded_impl!((), Box<Path>, PathBuf::into_boxed_path); |
1718 | | |
1719 | | //////////////////////////////////////////////////////////////////////////////// |
1720 | | |
1721 | | // If this were outside of the serde crate, it would just use: |
1722 | | // |
1723 | | // #[derive(Deserialize)] |
1724 | | // #[serde(variant_identifier)] |
1725 | | #[cfg(all(feature = "std", any(unix, windows)))] |
1726 | | variant_identifier! { |
1727 | | OsStringKind (Unix; b"Unix"; 0, Windows; b"Windows"; 1) |
1728 | | "`Unix` or `Windows`", |
1729 | | OSSTR_VARIANTS |
1730 | | } |
1731 | | |
1732 | | #[cfg(all(feature = "std", any(unix, windows)))] |
1733 | | struct OsStringVisitor; |
1734 | | |
1735 | | #[cfg(all(feature = "std", any(unix, windows)))] |
1736 | | impl<'de> Visitor<'de> for OsStringVisitor { |
1737 | | type Value = OsString; |
1738 | | |
1739 | 0 | fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { |
1740 | 0 | formatter.write_str("os string") |
1741 | 0 | } |
1742 | | |
1743 | | #[cfg(unix)] |
1744 | 0 | fn visit_enum<A>(self, data: A) -> Result<Self::Value, A::Error> |
1745 | 0 | where |
1746 | 0 | A: EnumAccess<'de>, |
1747 | 0 | { |
1748 | | use std::os::unix::ffi::OsStringExt; |
1749 | | |
1750 | 0 | match try!(data.variant()) { |
1751 | 0 | (OsStringKind::Unix, v) => v.newtype_variant().map(OsString::from_vec), |
1752 | 0 | (OsStringKind::Windows, _) => Err(Error::custom( |
1753 | 0 | "cannot deserialize Windows OS string on Unix", |
1754 | 0 | )), |
1755 | | } |
1756 | 0 | } |
1757 | | |
1758 | | #[cfg(windows)] |
1759 | | fn visit_enum<A>(self, data: A) -> Result<Self::Value, A::Error> |
1760 | | where |
1761 | | A: EnumAccess<'de>, |
1762 | | { |
1763 | | use std::os::windows::ffi::OsStringExt; |
1764 | | |
1765 | | match try!(data.variant()) { |
1766 | | (OsStringKind::Windows, v) => v |
1767 | | .newtype_variant::<Vec<u16>>() |
1768 | | .map(|vec| OsString::from_wide(&vec)), |
1769 | | (OsStringKind::Unix, _) => Err(Error::custom( |
1770 | | "cannot deserialize Unix OS string on Windows", |
1771 | | )), |
1772 | | } |
1773 | | } |
1774 | | } |
1775 | | |
1776 | | #[cfg(all(feature = "std", any(unix, windows)))] |
1777 | | impl<'de> Deserialize<'de> for OsString { |
1778 | 0 | fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> |
1779 | 0 | where |
1780 | 0 | D: Deserializer<'de>, |
1781 | 0 | { |
1782 | 0 | deserializer.deserialize_enum("OsString", OSSTR_VARIANTS, OsStringVisitor) |
1783 | 0 | } |
1784 | | } |
1785 | | |
1786 | | //////////////////////////////////////////////////////////////////////////////// |
1787 | | |
1788 | | #[cfg(any(feature = "std", feature = "alloc"))] |
1789 | | forwarded_impl!((T), Box<T>, Box::new); |
1790 | | |
1791 | | #[cfg(any(feature = "std", feature = "alloc"))] |
1792 | | forwarded_impl!((T), Box<[T]>, Vec::into_boxed_slice); |
1793 | | |
1794 | | #[cfg(any(feature = "std", feature = "alloc"))] |
1795 | | forwarded_impl!((), Box<str>, String::into_boxed_str); |
1796 | | |
1797 | | #[cfg(all(no_de_rc_dst, feature = "rc", any(feature = "std", feature = "alloc")))] |
1798 | | forwarded_impl! { |
1799 | | /// This impl requires the [`"rc"`] Cargo feature of Serde. |
1800 | | /// |
1801 | | /// Deserializing a data structure containing `Arc` will not attempt to |
1802 | | /// deduplicate `Arc` references to the same data. Every deserialized `Arc` |
1803 | | /// will end up with a strong count of 1. |
1804 | | /// |
1805 | | /// [`"rc"`]: https://serde.rs/feature-flags.html#-features-rc |
1806 | | (T), Arc<T>, Arc::new |
1807 | | } |
1808 | | |
1809 | | #[cfg(all(no_de_rc_dst, feature = "rc", any(feature = "std", feature = "alloc")))] |
1810 | | forwarded_impl! { |
1811 | | /// This impl requires the [`"rc"`] Cargo feature of Serde. |
1812 | | /// |
1813 | | /// Deserializing a data structure containing `Rc` will not attempt to |
1814 | | /// deduplicate `Rc` references to the same data. Every deserialized `Rc` |
1815 | | /// will end up with a strong count of 1. |
1816 | | /// |
1817 | | /// [`"rc"`]: https://serde.rs/feature-flags.html#-features-rc |
1818 | | (T), Rc<T>, Rc::new |
1819 | | } |
1820 | | |
1821 | | #[cfg(any(feature = "std", feature = "alloc"))] |
1822 | | impl<'de, 'a, T: ?Sized> Deserialize<'de> for Cow<'a, T> |
1823 | | where |
1824 | | T: ToOwned, |
1825 | | T::Owned: Deserialize<'de>, |
1826 | | { |
1827 | | #[inline] |
1828 | 0 | fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> |
1829 | 0 | where |
1830 | 0 | D: Deserializer<'de>, |
1831 | 0 | { |
1832 | 0 | T::Owned::deserialize(deserializer).map(Cow::Owned) |
1833 | 0 | } |
1834 | | } |
1835 | | |
1836 | | //////////////////////////////////////////////////////////////////////////////// |
1837 | | |
1838 | | /// This impl requires the [`"rc"`] Cargo feature of Serde. The resulting |
1839 | | /// `Weak<T>` has a reference count of 0 and cannot be upgraded. |
1840 | | /// |
1841 | | /// [`"rc"`]: https://serde.rs/feature-flags.html#-features-rc |
1842 | | #[cfg(all(feature = "rc", any(feature = "std", feature = "alloc")))] |
1843 | | impl<'de, T: ?Sized> Deserialize<'de> for RcWeak<T> |
1844 | | where |
1845 | | T: Deserialize<'de>, |
1846 | | { |
1847 | | fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> |
1848 | | where |
1849 | | D: Deserializer<'de>, |
1850 | | { |
1851 | | try!(Option::<T>::deserialize(deserializer)); |
1852 | | Ok(RcWeak::new()) |
1853 | | } |
1854 | | } |
1855 | | |
1856 | | /// This impl requires the [`"rc"`] Cargo feature of Serde. The resulting |
1857 | | /// `Weak<T>` has a reference count of 0 and cannot be upgraded. |
1858 | | /// |
1859 | | /// [`"rc"`]: https://serde.rs/feature-flags.html#-features-rc |
1860 | | #[cfg(all(feature = "rc", any(feature = "std", feature = "alloc")))] |
1861 | | impl<'de, T: ?Sized> Deserialize<'de> for ArcWeak<T> |
1862 | | where |
1863 | | T: Deserialize<'de>, |
1864 | | { |
1865 | | fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> |
1866 | | where |
1867 | | D: Deserializer<'de>, |
1868 | | { |
1869 | | try!(Option::<T>::deserialize(deserializer)); |
1870 | | Ok(ArcWeak::new()) |
1871 | | } |
1872 | | } |
1873 | | |
1874 | | //////////////////////////////////////////////////////////////////////////////// |
1875 | | |
1876 | | #[cfg(all( |
1877 | | not(no_de_rc_dst), |
1878 | | feature = "rc", |
1879 | | any(feature = "std", feature = "alloc") |
1880 | | ))] |
1881 | | macro_rules! box_forwarded_impl { |
1882 | | ( |
1883 | | $(#[doc = $doc:tt])* |
1884 | | $t:ident |
1885 | | ) => { |
1886 | | $(#[doc = $doc])* |
1887 | | impl<'de, T: ?Sized> Deserialize<'de> for $t<T> |
1888 | | where |
1889 | | Box<T>: Deserialize<'de>, |
1890 | | { |
1891 | | fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> |
1892 | | where |
1893 | | D: Deserializer<'de>, |
1894 | | { |
1895 | | Box::deserialize(deserializer).map(Into::into) |
1896 | | } |
1897 | | } |
1898 | | }; |
1899 | | } |
1900 | | |
1901 | | #[cfg(all( |
1902 | | not(no_de_rc_dst), |
1903 | | feature = "rc", |
1904 | | any(feature = "std", feature = "alloc") |
1905 | | ))] |
1906 | | box_forwarded_impl! { |
1907 | | /// This impl requires the [`"rc"`] Cargo feature of Serde. |
1908 | | /// |
1909 | | /// Deserializing a data structure containing `Rc` will not attempt to |
1910 | | /// deduplicate `Rc` references to the same data. Every deserialized `Rc` |
1911 | | /// will end up with a strong count of 1. |
1912 | | /// |
1913 | | /// [`"rc"`]: https://serde.rs/feature-flags.html#-features-rc |
1914 | | Rc |
1915 | | } |
1916 | | |
1917 | | #[cfg(all( |
1918 | | not(no_de_rc_dst), |
1919 | | feature = "rc", |
1920 | | any(feature = "std", feature = "alloc") |
1921 | | ))] |
1922 | | box_forwarded_impl! { |
1923 | | /// This impl requires the [`"rc"`] Cargo feature of Serde. |
1924 | | /// |
1925 | | /// Deserializing a data structure containing `Arc` will not attempt to |
1926 | | /// deduplicate `Arc` references to the same data. Every deserialized `Arc` |
1927 | | /// will end up with a strong count of 1. |
1928 | | /// |
1929 | | /// [`"rc"`]: https://serde.rs/feature-flags.html#-features-rc |
1930 | | Arc |
1931 | | } |
1932 | | |
1933 | | //////////////////////////////////////////////////////////////////////////////// |
1934 | | |
1935 | | impl<'de, T> Deserialize<'de> for Cell<T> |
1936 | | where |
1937 | | T: Deserialize<'de> + Copy, |
1938 | | { |
1939 | 0 | fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> |
1940 | 0 | where |
1941 | 0 | D: Deserializer<'de>, |
1942 | 0 | { |
1943 | 0 | T::deserialize(deserializer).map(Cell::new) |
1944 | 0 | } |
1945 | | } |
1946 | | |
1947 | | forwarded_impl!((T), RefCell<T>, RefCell::new); |
1948 | | |
1949 | | #[cfg(feature = "std")] |
1950 | | forwarded_impl!((T), Mutex<T>, Mutex::new); |
1951 | | |
1952 | | #[cfg(feature = "std")] |
1953 | | forwarded_impl!((T), RwLock<T>, RwLock::new); |
1954 | | |
1955 | | //////////////////////////////////////////////////////////////////////////////// |
1956 | | |
1957 | | // This is a cleaned-up version of the impl generated by: |
1958 | | // |
1959 | | // #[derive(Deserialize)] |
1960 | | // #[serde(deny_unknown_fields)] |
1961 | | // struct Duration { |
1962 | | // secs: u64, |
1963 | | // nanos: u32, |
1964 | | // } |
1965 | | #[cfg(any(feature = "std", not(no_core_duration)))] |
1966 | | impl<'de> Deserialize<'de> for Duration { |
1967 | 0 | fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> |
1968 | 0 | where |
1969 | 0 | D: Deserializer<'de>, |
1970 | 0 | { |
1971 | | // If this were outside of the serde crate, it would just use: |
1972 | | // |
1973 | | // #[derive(Deserialize)] |
1974 | | // #[serde(field_identifier, rename_all = "lowercase")] |
1975 | | enum Field { |
1976 | | Secs, |
1977 | | Nanos, |
1978 | | } |
1979 | | |
1980 | | impl<'de> Deserialize<'de> for Field { |
1981 | 0 | fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> |
1982 | 0 | where |
1983 | 0 | D: Deserializer<'de>, |
1984 | 0 | { |
1985 | | struct FieldVisitor; |
1986 | | |
1987 | | impl<'de> Visitor<'de> for FieldVisitor { |
1988 | | type Value = Field; |
1989 | | |
1990 | 0 | fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { |
1991 | 0 | formatter.write_str("`secs` or `nanos`") |
1992 | 0 | } |
1993 | | |
1994 | 0 | fn visit_str<E>(self, value: &str) -> Result<Self::Value, E> |
1995 | 0 | where |
1996 | 0 | E: Error, |
1997 | 0 | { |
1998 | 0 | match value { |
1999 | 0 | "secs" => Ok(Field::Secs), |
2000 | 0 | "nanos" => Ok(Field::Nanos), |
2001 | 0 | _ => Err(Error::unknown_field(value, FIELDS)), |
2002 | | } |
2003 | 0 | } |
2004 | | |
2005 | 0 | fn visit_bytes<E>(self, value: &[u8]) -> Result<Self::Value, E> |
2006 | 0 | where |
2007 | 0 | E: Error, |
2008 | 0 | { |
2009 | 0 | match value { |
2010 | 0 | b"secs" => Ok(Field::Secs), |
2011 | 0 | b"nanos" => Ok(Field::Nanos), |
2012 | | _ => { |
2013 | 0 | let value = ::__private::from_utf8_lossy(value); |
2014 | 0 | Err(Error::unknown_field(&*value, FIELDS)) |
2015 | | } |
2016 | | } |
2017 | 0 | } |
2018 | | } |
2019 | | |
2020 | 0 | deserializer.deserialize_identifier(FieldVisitor) |
2021 | 0 | } |
2022 | | } |
2023 | | |
2024 | 0 | fn check_overflow<E>(secs: u64, nanos: u32) -> Result<(), E> |
2025 | 0 | where |
2026 | 0 | E: Error, |
2027 | 0 | { |
2028 | | static NANOS_PER_SEC: u32 = 1_000_000_000; |
2029 | 0 | match secs.checked_add((nanos / NANOS_PER_SEC) as u64) { |
2030 | 0 | Some(_) => Ok(()), |
2031 | 0 | None => Err(E::custom("overflow deserializing Duration")), |
2032 | | } |
2033 | 0 | } |
2034 | | |
2035 | | struct DurationVisitor; |
2036 | | |
2037 | | impl<'de> Visitor<'de> for DurationVisitor { |
2038 | | type Value = Duration; |
2039 | | |
2040 | 0 | fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { |
2041 | 0 | formatter.write_str("struct Duration") |
2042 | 0 | } |
2043 | | |
2044 | 0 | fn visit_seq<A>(self, mut seq: A) -> Result<Self::Value, A::Error> |
2045 | 0 | where |
2046 | 0 | A: SeqAccess<'de>, |
2047 | 0 | { |
2048 | 0 | let secs: u64 = match try!(seq.next_element()) { |
2049 | 0 | Some(value) => value, |
2050 | | None => { |
2051 | 0 | return Err(Error::invalid_length(0, &self)); |
2052 | | } |
2053 | | }; |
2054 | 0 | let nanos: u32 = match try!(seq.next_element()) { |
2055 | 0 | Some(value) => value, |
2056 | | None => { |
2057 | 0 | return Err(Error::invalid_length(1, &self)); |
2058 | | } |
2059 | | }; |
2060 | 0 | try!(check_overflow(secs, nanos)); |
2061 | 0 | Ok(Duration::new(secs, nanos)) |
2062 | 0 | } |
2063 | | |
2064 | 0 | fn visit_map<A>(self, mut map: A) -> Result<Self::Value, A::Error> |
2065 | 0 | where |
2066 | 0 | A: MapAccess<'de>, |
2067 | 0 | { |
2068 | 0 | let mut secs: Option<u64> = None; |
2069 | 0 | let mut nanos: Option<u32> = None; |
2070 | 0 | while let Some(key) = try!(map.next_key()) { |
2071 | 0 | match key { |
2072 | | Field::Secs => { |
2073 | 0 | if secs.is_some() { |
2074 | 0 | return Err(<A::Error as Error>::duplicate_field("secs")); |
2075 | 0 | } |
2076 | 0 | secs = Some(try!(map.next_value())); |
2077 | | } |
2078 | | Field::Nanos => { |
2079 | 0 | if nanos.is_some() { |
2080 | 0 | return Err(<A::Error as Error>::duplicate_field("nanos")); |
2081 | 0 | } |
2082 | 0 | nanos = Some(try!(map.next_value())); |
2083 | | } |
2084 | | } |
2085 | | } |
2086 | 0 | let secs = match secs { |
2087 | 0 | Some(secs) => secs, |
2088 | 0 | None => return Err(<A::Error as Error>::missing_field("secs")), |
2089 | | }; |
2090 | 0 | let nanos = match nanos { |
2091 | 0 | Some(nanos) => nanos, |
2092 | 0 | None => return Err(<A::Error as Error>::missing_field("nanos")), |
2093 | | }; |
2094 | 0 | try!(check_overflow(secs, nanos)); |
2095 | 0 | Ok(Duration::new(secs, nanos)) |
2096 | 0 | } |
2097 | | } |
2098 | | |
2099 | | const FIELDS: &'static [&'static str] = &["secs", "nanos"]; |
2100 | 0 | deserializer.deserialize_struct("Duration", FIELDS, DurationVisitor) |
2101 | 0 | } |
2102 | | } |
2103 | | |
2104 | | //////////////////////////////////////////////////////////////////////////////// |
2105 | | |
2106 | | #[cfg(feature = "std")] |
2107 | | impl<'de> Deserialize<'de> for SystemTime { |
2108 | 0 | fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> |
2109 | 0 | where |
2110 | 0 | D: Deserializer<'de>, |
2111 | 0 | { |
2112 | | // Reuse duration |
2113 | | enum Field { |
2114 | | Secs, |
2115 | | Nanos, |
2116 | | } |
2117 | | |
2118 | | impl<'de> Deserialize<'de> for Field { |
2119 | 0 | fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> |
2120 | 0 | where |
2121 | 0 | D: Deserializer<'de>, |
2122 | 0 | { |
2123 | | struct FieldVisitor; |
2124 | | |
2125 | | impl<'de> Visitor<'de> for FieldVisitor { |
2126 | | type Value = Field; |
2127 | | |
2128 | 0 | fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { |
2129 | 0 | formatter.write_str("`secs_since_epoch` or `nanos_since_epoch`") |
2130 | 0 | } |
2131 | | |
2132 | 0 | fn visit_str<E>(self, value: &str) -> Result<Self::Value, E> |
2133 | 0 | where |
2134 | 0 | E: Error, |
2135 | 0 | { |
2136 | 0 | match value { |
2137 | 0 | "secs_since_epoch" => Ok(Field::Secs), |
2138 | 0 | "nanos_since_epoch" => Ok(Field::Nanos), |
2139 | 0 | _ => Err(Error::unknown_field(value, FIELDS)), |
2140 | | } |
2141 | 0 | } |
2142 | | |
2143 | 0 | fn visit_bytes<E>(self, value: &[u8]) -> Result<Self::Value, E> |
2144 | 0 | where |
2145 | 0 | E: Error, |
2146 | 0 | { |
2147 | 0 | match value { |
2148 | 0 | b"secs_since_epoch" => Ok(Field::Secs), |
2149 | 0 | b"nanos_since_epoch" => Ok(Field::Nanos), |
2150 | | _ => { |
2151 | 0 | let value = String::from_utf8_lossy(value); |
2152 | 0 | Err(Error::unknown_field(&value, FIELDS)) |
2153 | | } |
2154 | | } |
2155 | 0 | } |
2156 | | } |
2157 | | |
2158 | 0 | deserializer.deserialize_identifier(FieldVisitor) |
2159 | 0 | } |
2160 | | } |
2161 | | |
2162 | 0 | fn check_overflow<E>(secs: u64, nanos: u32) -> Result<(), E> |
2163 | 0 | where |
2164 | 0 | E: Error, |
2165 | 0 | { |
2166 | | static NANOS_PER_SEC: u32 = 1_000_000_000; |
2167 | 0 | match secs.checked_add((nanos / NANOS_PER_SEC) as u64) { |
2168 | 0 | Some(_) => Ok(()), |
2169 | 0 | None => Err(E::custom("overflow deserializing SystemTime epoch offset")), |
2170 | | } |
2171 | 0 | } |
2172 | | |
2173 | | struct DurationVisitor; |
2174 | | |
2175 | | impl<'de> Visitor<'de> for DurationVisitor { |
2176 | | type Value = Duration; |
2177 | | |
2178 | 0 | fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { |
2179 | 0 | formatter.write_str("struct SystemTime") |
2180 | 0 | } |
2181 | | |
2182 | 0 | fn visit_seq<A>(self, mut seq: A) -> Result<Self::Value, A::Error> |
2183 | 0 | where |
2184 | 0 | A: SeqAccess<'de>, |
2185 | 0 | { |
2186 | 0 | let secs: u64 = match try!(seq.next_element()) { |
2187 | 0 | Some(value) => value, |
2188 | | None => { |
2189 | 0 | return Err(Error::invalid_length(0, &self)); |
2190 | | } |
2191 | | }; |
2192 | 0 | let nanos: u32 = match try!(seq.next_element()) { |
2193 | 0 | Some(value) => value, |
2194 | | None => { |
2195 | 0 | return Err(Error::invalid_length(1, &self)); |
2196 | | } |
2197 | | }; |
2198 | 0 | try!(check_overflow(secs, nanos)); |
2199 | 0 | Ok(Duration::new(secs, nanos)) |
2200 | 0 | } |
2201 | | |
2202 | 0 | fn visit_map<A>(self, mut map: A) -> Result<Self::Value, A::Error> |
2203 | 0 | where |
2204 | 0 | A: MapAccess<'de>, |
2205 | 0 | { |
2206 | 0 | let mut secs: Option<u64> = None; |
2207 | 0 | let mut nanos: Option<u32> = None; |
2208 | 0 | while let Some(key) = try!(map.next_key()) { |
2209 | 0 | match key { |
2210 | | Field::Secs => { |
2211 | 0 | if secs.is_some() { |
2212 | 0 | return Err(<A::Error as Error>::duplicate_field( |
2213 | 0 | "secs_since_epoch", |
2214 | 0 | )); |
2215 | 0 | } |
2216 | 0 | secs = Some(try!(map.next_value())); |
2217 | | } |
2218 | | Field::Nanos => { |
2219 | 0 | if nanos.is_some() { |
2220 | 0 | return Err(<A::Error as Error>::duplicate_field( |
2221 | 0 | "nanos_since_epoch", |
2222 | 0 | )); |
2223 | 0 | } |
2224 | 0 | nanos = Some(try!(map.next_value())); |
2225 | | } |
2226 | | } |
2227 | | } |
2228 | 0 | let secs = match secs { |
2229 | 0 | Some(secs) => secs, |
2230 | 0 | None => return Err(<A::Error as Error>::missing_field("secs_since_epoch")), |
2231 | | }; |
2232 | 0 | let nanos = match nanos { |
2233 | 0 | Some(nanos) => nanos, |
2234 | 0 | None => return Err(<A::Error as Error>::missing_field("nanos_since_epoch")), |
2235 | | }; |
2236 | 0 | try!(check_overflow(secs, nanos)); |
2237 | 0 | Ok(Duration::new(secs, nanos)) |
2238 | 0 | } |
2239 | | } |
2240 | | |
2241 | | const FIELDS: &'static [&'static str] = &["secs_since_epoch", "nanos_since_epoch"]; |
2242 | 0 | let duration = try!(deserializer.deserialize_struct("SystemTime", FIELDS, DurationVisitor)); |
2243 | | #[cfg(not(no_systemtime_checked_add))] |
2244 | 0 | let ret = UNIX_EPOCH |
2245 | 0 | .checked_add(duration) |
2246 | 0 | .ok_or_else(|| D::Error::custom("overflow deserializing SystemTime")); |
2247 | 0 | #[cfg(no_systemtime_checked_add)] |
2248 | 0 | let ret = Ok(UNIX_EPOCH + duration); |
2249 | 0 | ret |
2250 | 0 | } |
2251 | | } |
2252 | | |
2253 | | //////////////////////////////////////////////////////////////////////////////// |
2254 | | |
2255 | | // Similar to: |
2256 | | // |
2257 | | // #[derive(Deserialize)] |
2258 | | // #[serde(deny_unknown_fields)] |
2259 | | // struct Range { |
2260 | | // start: u64, |
2261 | | // end: u32, |
2262 | | // } |
2263 | | impl<'de, Idx> Deserialize<'de> for Range<Idx> |
2264 | | where |
2265 | | Idx: Deserialize<'de>, |
2266 | | { |
2267 | 0 | fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> |
2268 | 0 | where |
2269 | 0 | D: Deserializer<'de>, |
2270 | 0 | { |
2271 | 0 | let (start, end) = try!(deserializer.deserialize_struct( |
2272 | 0 | "Range", |
2273 | 0 | range::FIELDS, |
2274 | 0 | range::RangeVisitor { |
2275 | 0 | expecting: "struct Range", |
2276 | 0 | phantom: PhantomData, |
2277 | 0 | }, |
2278 | 0 | )); |
2279 | 0 | Ok(start..end) |
2280 | 0 | } |
2281 | | } |
2282 | | |
2283 | | #[cfg(not(no_range_inclusive))] |
2284 | | impl<'de, Idx> Deserialize<'de> for RangeInclusive<Idx> |
2285 | | where |
2286 | | Idx: Deserialize<'de>, |
2287 | | { |
2288 | 0 | fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> |
2289 | 0 | where |
2290 | 0 | D: Deserializer<'de>, |
2291 | 0 | { |
2292 | 0 | let (start, end) = try!(deserializer.deserialize_struct( |
2293 | 0 | "RangeInclusive", |
2294 | 0 | range::FIELDS, |
2295 | 0 | range::RangeVisitor { |
2296 | 0 | expecting: "struct RangeInclusive", |
2297 | 0 | phantom: PhantomData, |
2298 | 0 | }, |
2299 | 0 | )); |
2300 | 0 | Ok(RangeInclusive::new(start, end)) |
2301 | 0 | } |
2302 | | } |
2303 | | |
2304 | | mod range { |
2305 | | use lib::*; |
2306 | | |
2307 | | use de::{Deserialize, Deserializer, Error, MapAccess, SeqAccess, Visitor}; |
2308 | | |
2309 | | pub const FIELDS: &'static [&'static str] = &["start", "end"]; |
2310 | | |
2311 | | // If this were outside of the serde crate, it would just use: |
2312 | | // |
2313 | | // #[derive(Deserialize)] |
2314 | | // #[serde(field_identifier, rename_all = "lowercase")] |
2315 | | enum Field { |
2316 | | Start, |
2317 | | End, |
2318 | | } |
2319 | | |
2320 | | impl<'de> Deserialize<'de> for Field { |
2321 | 0 | fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> |
2322 | 0 | where |
2323 | 0 | D: Deserializer<'de>, |
2324 | 0 | { |
2325 | | struct FieldVisitor; |
2326 | | |
2327 | | impl<'de> Visitor<'de> for FieldVisitor { |
2328 | | type Value = Field; |
2329 | | |
2330 | 0 | fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { |
2331 | 0 | formatter.write_str("`start` or `end`") |
2332 | 0 | } |
2333 | | |
2334 | 0 | fn visit_str<E>(self, value: &str) -> Result<Self::Value, E> |
2335 | 0 | where |
2336 | 0 | E: Error, |
2337 | 0 | { |
2338 | 0 | match value { |
2339 | 0 | "start" => Ok(Field::Start), |
2340 | 0 | "end" => Ok(Field::End), |
2341 | 0 | _ => Err(Error::unknown_field(value, FIELDS)), |
2342 | | } |
2343 | 0 | } |
2344 | | |
2345 | 0 | fn visit_bytes<E>(self, value: &[u8]) -> Result<Self::Value, E> |
2346 | 0 | where |
2347 | 0 | E: Error, |
2348 | 0 | { |
2349 | 0 | match value { |
2350 | 0 | b"start" => Ok(Field::Start), |
2351 | 0 | b"end" => Ok(Field::End), |
2352 | | _ => { |
2353 | 0 | let value = ::__private::from_utf8_lossy(value); |
2354 | 0 | Err(Error::unknown_field(&*value, FIELDS)) |
2355 | | } |
2356 | | } |
2357 | 0 | } |
2358 | | } |
2359 | | |
2360 | 0 | deserializer.deserialize_identifier(FieldVisitor) |
2361 | 0 | } |
2362 | | } |
2363 | | |
2364 | | pub struct RangeVisitor<Idx> { |
2365 | | pub expecting: &'static str, |
2366 | | pub phantom: PhantomData<Idx>, |
2367 | | } |
2368 | | |
2369 | | impl<'de, Idx> Visitor<'de> for RangeVisitor<Idx> |
2370 | | where |
2371 | | Idx: Deserialize<'de>, |
2372 | | { |
2373 | | type Value = (Idx, Idx); |
2374 | | |
2375 | 0 | fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { |
2376 | 0 | formatter.write_str(self.expecting) |
2377 | 0 | } |
2378 | | |
2379 | 0 | fn visit_seq<A>(self, mut seq: A) -> Result<Self::Value, A::Error> |
2380 | 0 | where |
2381 | 0 | A: SeqAccess<'de>, |
2382 | 0 | { |
2383 | 0 | let start: Idx = match try!(seq.next_element()) { |
2384 | 0 | Some(value) => value, |
2385 | | None => { |
2386 | 0 | return Err(Error::invalid_length(0, &self)); |
2387 | | } |
2388 | | }; |
2389 | 0 | let end: Idx = match try!(seq.next_element()) { |
2390 | 0 | Some(value) => value, |
2391 | | None => { |
2392 | 0 | return Err(Error::invalid_length(1, &self)); |
2393 | | } |
2394 | | }; |
2395 | 0 | Ok((start, end)) |
2396 | 0 | } |
2397 | | |
2398 | 0 | fn visit_map<A>(self, mut map: A) -> Result<Self::Value, A::Error> |
2399 | 0 | where |
2400 | 0 | A: MapAccess<'de>, |
2401 | 0 | { |
2402 | 0 | let mut start: Option<Idx> = None; |
2403 | 0 | let mut end: Option<Idx> = None; |
2404 | 0 | while let Some(key) = try!(map.next_key()) { |
2405 | 0 | match key { |
2406 | | Field::Start => { |
2407 | 0 | if start.is_some() { |
2408 | 0 | return Err(<A::Error as Error>::duplicate_field("start")); |
2409 | 0 | } |
2410 | 0 | start = Some(try!(map.next_value())); |
2411 | | } |
2412 | | Field::End => { |
2413 | 0 | if end.is_some() { |
2414 | 0 | return Err(<A::Error as Error>::duplicate_field("end")); |
2415 | 0 | } |
2416 | 0 | end = Some(try!(map.next_value())); |
2417 | | } |
2418 | | } |
2419 | | } |
2420 | 0 | let start = match start { |
2421 | 0 | Some(start) => start, |
2422 | 0 | None => return Err(<A::Error as Error>::missing_field("start")), |
2423 | | }; |
2424 | 0 | let end = match end { |
2425 | 0 | Some(end) => end, |
2426 | 0 | None => return Err(<A::Error as Error>::missing_field("end")), |
2427 | | }; |
2428 | 0 | Ok((start, end)) |
2429 | 0 | } |
2430 | | } |
2431 | | } |
2432 | | |
2433 | | //////////////////////////////////////////////////////////////////////////////// |
2434 | | |
2435 | | #[cfg(any(not(no_ops_bound), all(feature = "std", not(no_collections_bound))))] |
2436 | | impl<'de, T> Deserialize<'de> for Bound<T> |
2437 | | where |
2438 | | T: Deserialize<'de>, |
2439 | | { |
2440 | 0 | fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> |
2441 | 0 | where |
2442 | 0 | D: Deserializer<'de>, |
2443 | 0 | { |
2444 | | enum Field { |
2445 | | Unbounded, |
2446 | | Included, |
2447 | | Excluded, |
2448 | | } |
2449 | | |
2450 | | impl<'de> Deserialize<'de> for Field { |
2451 | | #[inline] |
2452 | 0 | fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> |
2453 | 0 | where |
2454 | 0 | D: Deserializer<'de>, |
2455 | 0 | { |
2456 | | struct FieldVisitor; |
2457 | | |
2458 | | impl<'de> Visitor<'de> for FieldVisitor { |
2459 | | type Value = Field; |
2460 | | |
2461 | 0 | fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { |
2462 | 0 | formatter.write_str("`Unbounded`, `Included` or `Excluded`") |
2463 | 0 | } |
2464 | | |
2465 | 0 | fn visit_u64<E>(self, value: u64) -> Result<Self::Value, E> |
2466 | 0 | where |
2467 | 0 | E: Error, |
2468 | 0 | { |
2469 | 0 | match value { |
2470 | 0 | 0 => Ok(Field::Unbounded), |
2471 | 0 | 1 => Ok(Field::Included), |
2472 | 0 | 2 => Ok(Field::Excluded), |
2473 | 0 | _ => Err(Error::invalid_value(Unexpected::Unsigned(value), &self)), |
2474 | | } |
2475 | 0 | } |
2476 | | |
2477 | 0 | fn visit_str<E>(self, value: &str) -> Result<Self::Value, E> |
2478 | 0 | where |
2479 | 0 | E: Error, |
2480 | 0 | { |
2481 | 0 | match value { |
2482 | 0 | "Unbounded" => Ok(Field::Unbounded), |
2483 | 0 | "Included" => Ok(Field::Included), |
2484 | 0 | "Excluded" => Ok(Field::Excluded), |
2485 | 0 | _ => Err(Error::unknown_variant(value, VARIANTS)), |
2486 | | } |
2487 | 0 | } |
2488 | | |
2489 | 0 | fn visit_bytes<E>(self, value: &[u8]) -> Result<Self::Value, E> |
2490 | 0 | where |
2491 | 0 | E: Error, |
2492 | 0 | { |
2493 | 0 | match value { |
2494 | 0 | b"Unbounded" => Ok(Field::Unbounded), |
2495 | 0 | b"Included" => Ok(Field::Included), |
2496 | 0 | b"Excluded" => Ok(Field::Excluded), |
2497 | 0 | _ => match str::from_utf8(value) { |
2498 | 0 | Ok(value) => Err(Error::unknown_variant(value, VARIANTS)), |
2499 | | Err(_) => { |
2500 | 0 | Err(Error::invalid_value(Unexpected::Bytes(value), &self)) |
2501 | | } |
2502 | | }, |
2503 | | } |
2504 | 0 | } |
2505 | | } |
2506 | | |
2507 | 0 | deserializer.deserialize_identifier(FieldVisitor) |
2508 | 0 | } |
2509 | | } |
2510 | | |
2511 | | struct BoundVisitor<T>(PhantomData<Bound<T>>); |
2512 | | |
2513 | | impl<'de, T> Visitor<'de> for BoundVisitor<T> |
2514 | | where |
2515 | | T: Deserialize<'de>, |
2516 | | { |
2517 | | type Value = Bound<T>; |
2518 | | |
2519 | 0 | fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { |
2520 | 0 | formatter.write_str("enum Bound") |
2521 | 0 | } |
2522 | | |
2523 | 0 | fn visit_enum<A>(self, data: A) -> Result<Self::Value, A::Error> |
2524 | 0 | where |
2525 | 0 | A: EnumAccess<'de>, |
2526 | 0 | { |
2527 | 0 | match try!(data.variant()) { |
2528 | 0 | (Field::Unbounded, v) => v.unit_variant().map(|()| Bound::Unbounded), |
2529 | 0 | (Field::Included, v) => v.newtype_variant().map(Bound::Included), |
2530 | 0 | (Field::Excluded, v) => v.newtype_variant().map(Bound::Excluded), |
2531 | | } |
2532 | 0 | } |
2533 | | } |
2534 | | |
2535 | | const VARIANTS: &'static [&'static str] = &["Unbounded", "Included", "Excluded"]; |
2536 | | |
2537 | 0 | deserializer.deserialize_enum("Bound", VARIANTS, BoundVisitor(PhantomData)) |
2538 | 0 | } |
2539 | | } |
2540 | | |
2541 | | //////////////////////////////////////////////////////////////////////////////// |
2542 | | |
2543 | | impl<'de, T, E> Deserialize<'de> for Result<T, E> |
2544 | | where |
2545 | | T: Deserialize<'de>, |
2546 | | E: Deserialize<'de>, |
2547 | | { |
2548 | 0 | fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> |
2549 | 0 | where |
2550 | 0 | D: Deserializer<'de>, |
2551 | 0 | { |
2552 | | // If this were outside of the serde crate, it would just use: |
2553 | | // |
2554 | | // #[derive(Deserialize)] |
2555 | | // #[serde(variant_identifier)] |
2556 | | enum Field { |
2557 | | Ok, |
2558 | | Err, |
2559 | | } |
2560 | | |
2561 | | impl<'de> Deserialize<'de> for Field { |
2562 | | #[inline] |
2563 | 0 | fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> |
2564 | 0 | where |
2565 | 0 | D: Deserializer<'de>, |
2566 | 0 | { |
2567 | | struct FieldVisitor; |
2568 | | |
2569 | | impl<'de> Visitor<'de> for FieldVisitor { |
2570 | | type Value = Field; |
2571 | | |
2572 | 0 | fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { |
2573 | 0 | formatter.write_str("`Ok` or `Err`") |
2574 | 0 | } |
2575 | | |
2576 | 0 | fn visit_u64<E>(self, value: u64) -> Result<Self::Value, E> |
2577 | 0 | where |
2578 | 0 | E: Error, |
2579 | 0 | { |
2580 | 0 | match value { |
2581 | 0 | 0 => Ok(Field::Ok), |
2582 | 0 | 1 => Ok(Field::Err), |
2583 | 0 | _ => Err(Error::invalid_value(Unexpected::Unsigned(value), &self)), |
2584 | | } |
2585 | 0 | } |
2586 | | |
2587 | 0 | fn visit_str<E>(self, value: &str) -> Result<Self::Value, E> |
2588 | 0 | where |
2589 | 0 | E: Error, |
2590 | 0 | { |
2591 | 0 | match value { |
2592 | 0 | "Ok" => Ok(Field::Ok), |
2593 | 0 | "Err" => Ok(Field::Err), |
2594 | 0 | _ => Err(Error::unknown_variant(value, VARIANTS)), |
2595 | | } |
2596 | 0 | } |
2597 | | |
2598 | 0 | fn visit_bytes<E>(self, value: &[u8]) -> Result<Self::Value, E> |
2599 | 0 | where |
2600 | 0 | E: Error, |
2601 | 0 | { |
2602 | 0 | match value { |
2603 | 0 | b"Ok" => Ok(Field::Ok), |
2604 | 0 | b"Err" => Ok(Field::Err), |
2605 | 0 | _ => match str::from_utf8(value) { |
2606 | 0 | Ok(value) => Err(Error::unknown_variant(value, VARIANTS)), |
2607 | | Err(_) => { |
2608 | 0 | Err(Error::invalid_value(Unexpected::Bytes(value), &self)) |
2609 | | } |
2610 | | }, |
2611 | | } |
2612 | 0 | } |
2613 | | } |
2614 | | |
2615 | 0 | deserializer.deserialize_identifier(FieldVisitor) |
2616 | 0 | } |
2617 | | } |
2618 | | |
2619 | | struct ResultVisitor<T, E>(PhantomData<Result<T, E>>); |
2620 | | |
2621 | | impl<'de, T, E> Visitor<'de> for ResultVisitor<T, E> |
2622 | | where |
2623 | | T: Deserialize<'de>, |
2624 | | E: Deserialize<'de>, |
2625 | | { |
2626 | | type Value = Result<T, E>; |
2627 | | |
2628 | 0 | fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { |
2629 | 0 | formatter.write_str("enum Result") |
2630 | 0 | } |
2631 | | |
2632 | 0 | fn visit_enum<A>(self, data: A) -> Result<Self::Value, A::Error> |
2633 | 0 | where |
2634 | 0 | A: EnumAccess<'de>, |
2635 | 0 | { |
2636 | 0 | match try!(data.variant()) { |
2637 | 0 | (Field::Ok, v) => v.newtype_variant().map(Ok), |
2638 | 0 | (Field::Err, v) => v.newtype_variant().map(Err), |
2639 | | } |
2640 | 0 | } |
2641 | | } |
2642 | | |
2643 | | const VARIANTS: &'static [&'static str] = &["Ok", "Err"]; |
2644 | | |
2645 | 0 | deserializer.deserialize_enum("Result", VARIANTS, ResultVisitor(PhantomData)) |
2646 | 0 | } |
2647 | | } |
2648 | | |
2649 | | //////////////////////////////////////////////////////////////////////////////// |
2650 | | |
2651 | | impl<'de, T> Deserialize<'de> for Wrapping<T> |
2652 | | where |
2653 | | T: Deserialize<'de>, |
2654 | | { |
2655 | 0 | fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> |
2656 | 0 | where |
2657 | 0 | D: Deserializer<'de>, |
2658 | 0 | { |
2659 | 0 | Deserialize::deserialize(deserializer).map(Wrapping) |
2660 | 0 | } |
2661 | | } |
2662 | | |
2663 | | #[cfg(all(feature = "std", not(no_std_atomic)))] |
2664 | | macro_rules! atomic_impl { |
2665 | | ($($ty:ident $size:expr)*) => { |
2666 | | $( |
2667 | | #[cfg(any(no_target_has_atomic, target_has_atomic = $size))] |
2668 | | impl<'de> Deserialize<'de> for $ty { |
2669 | 0 | fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> |
2670 | 0 | where |
2671 | 0 | D: Deserializer<'de>, |
2672 | 0 | { |
2673 | 0 | Deserialize::deserialize(deserializer).map(Self::new) |
2674 | 0 | } Unexecuted instantiation: <core::sync::atomic::AtomicBool as serde::de::Deserialize>::deserialize::<_> Unexecuted instantiation: <core::sync::atomic::AtomicI8 as serde::de::Deserialize>::deserialize::<_> Unexecuted instantiation: <core::sync::atomic::AtomicI16 as serde::de::Deserialize>::deserialize::<_> Unexecuted instantiation: <core::sync::atomic::AtomicI32 as serde::de::Deserialize>::deserialize::<_> Unexecuted instantiation: <core::sync::atomic::AtomicIsize as serde::de::Deserialize>::deserialize::<_> Unexecuted instantiation: <core::sync::atomic::AtomicU8 as serde::de::Deserialize>::deserialize::<_> Unexecuted instantiation: <core::sync::atomic::AtomicU16 as serde::de::Deserialize>::deserialize::<_> Unexecuted instantiation: <core::sync::atomic::AtomicU32 as serde::de::Deserialize>::deserialize::<_> Unexecuted instantiation: <core::sync::atomic::AtomicUsize as serde::de::Deserialize>::deserialize::<_> Unexecuted instantiation: <core::sync::atomic::AtomicI64 as serde::de::Deserialize>::deserialize::<_> Unexecuted instantiation: <core::sync::atomic::AtomicU64 as serde::de::Deserialize>::deserialize::<_> |
2675 | | } |
2676 | | )* |
2677 | | }; |
2678 | | } |
2679 | | |
2680 | | #[cfg(all(feature = "std", not(no_std_atomic)))] |
2681 | | atomic_impl! { |
2682 | | AtomicBool "8" |
2683 | | AtomicI8 "8" |
2684 | | AtomicI16 "16" |
2685 | | AtomicI32 "32" |
2686 | | AtomicIsize "ptr" |
2687 | | AtomicU8 "8" |
2688 | | AtomicU16 "16" |
2689 | | AtomicU32 "32" |
2690 | | AtomicUsize "ptr" |
2691 | | } |
2692 | | |
2693 | | #[cfg(all(feature = "std", not(no_std_atomic64)))] |
2694 | | atomic_impl! { |
2695 | | AtomicI64 "64" |
2696 | | AtomicU64 "64" |
2697 | | } |
2698 | | |
2699 | | #[cfg(feature = "std")] |
2700 | | struct FromStrVisitor<T> { |
2701 | | expecting: &'static str, |
2702 | | ty: PhantomData<T>, |
2703 | | } |
2704 | | |
2705 | | #[cfg(feature = "std")] |
2706 | | impl<T> FromStrVisitor<T> { |
2707 | 0 | fn new(expecting: &'static str) -> Self { |
2708 | 0 | FromStrVisitor { |
2709 | 0 | expecting: expecting, |
2710 | 0 | ty: PhantomData, |
2711 | 0 | } |
2712 | 0 | } |
2713 | | } |
2714 | | |
2715 | | #[cfg(feature = "std")] |
2716 | | impl<'de, T> Visitor<'de> for FromStrVisitor<T> |
2717 | | where |
2718 | | T: str::FromStr, |
2719 | | T::Err: fmt::Display, |
2720 | | { |
2721 | | type Value = T; |
2722 | | |
2723 | 0 | fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { |
2724 | 0 | formatter.write_str(self.expecting) |
2725 | 0 | } |
2726 | | |
2727 | 0 | fn visit_str<E>(self, s: &str) -> Result<Self::Value, E> |
2728 | 0 | where |
2729 | 0 | E: Error, |
2730 | 0 | { |
2731 | 0 | s.parse().map_err(Error::custom) |
2732 | 0 | } |
2733 | | } |