Coverage Report

Created: 2023-04-25 07:07

/rust/registry/src/index.crates.io-6f17d22bba15001f/serde-1.0.160/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
    fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
23
        formatter.write_str("unit")
24
    }
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
    }
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
    }
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
    fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
61
        formatter.write_str("a boolean")
62
    }
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
    }
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
    }
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
0
                struct NonZeroVisitor;
94
0
95
0
                impl<'de> Visitor<'de> for NonZeroVisitor {
96
0
                    type Value = num::$nonzero;
97
0
98
0
                    fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
99
0
                        formatter.write_str(concat!("a nonzero ", stringify!($primitive)))
100
0
                    }
101
0
102
0
                    $($($method!(nonzero $primitive $val : $visit);)*)*
103
0
                }
104
0
105
0
                deserializer.$deserialize(NonZeroVisitor)
106
0
            }
Unexecuted instantiation: <core::num::nonzero::NonZeroI32 as serde::de::Deserialize>::deserialize::<_>
Unexecuted instantiation: <core::num::nonzero::NonZeroU128 as serde::de::Deserialize>::deserialize::<_>
Unexecuted instantiation: <core::num::nonzero::NonZeroU64 as serde::de::Deserialize>::deserialize::<_>
Unexecuted instantiation: <core::num::nonzero::NonZeroU8 as serde::de::Deserialize>::deserialize::<_>
Unexecuted instantiation: <core::num::nonzero::NonZeroU16 as serde::de::Deserialize>::deserialize::<_>
Unexecuted instantiation: <core::num::nonzero::NonZeroI8 as serde::de::Deserialize>::deserialize::<_>
Unexecuted instantiation: <core::num::nonzero::NonZeroUsize as serde::de::Deserialize>::deserialize::<_>
Unexecuted instantiation: <core::num::nonzero::NonZeroI128 as serde::de::Deserialize>::deserialize::<_>
Unexecuted instantiation: <core::num::nonzero::NonZeroI64 as serde::de::Deserialize>::deserialize::<_>
Unexecuted instantiation: <core::num::nonzero::NonZeroIsize as serde::de::Deserialize>::deserialize::<_>
Unexecuted instantiation: <core::num::nonzero::NonZeroI16 as serde::de::Deserialize>::deserialize::<_>
Unexecuted instantiation: <core::num::nonzero::NonZeroU32 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
0
                struct PrimitiveVisitor;
118
0
119
0
                impl<'de> Visitor<'de> for PrimitiveVisitor {
120
0
                    type Value = $primitive;
121
0
122
0
                    fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
123
0
                        formatter.write_str(stringify!($primitive))
124
0
                    }
125
0
126
0
                    $($($method!($val : $visit);)*)*
127
0
                }
128
0
129
0
                deserializer.$deserialize(PrimitiveVisitor)
130
0
            }
Unexecuted instantiation: <i8 as serde::de::Deserialize>::deserialize::<_>
Unexecuted instantiation: <i128 as serde::de::Deserialize>::deserialize::<_>
Unexecuted instantiation: <usize as serde::de::Deserialize>::deserialize::<_>
Unexecuted instantiation: <u128 as serde::de::Deserialize>::deserialize::<_>
Unexecuted instantiation: <i64 as serde::de::Deserialize>::deserialize::<_>
Unexecuted instantiation: <f32 as serde::de::Deserialize>::deserialize::<_>
Unexecuted instantiation: <isize as serde::de::Deserialize>::deserialize::<_>
Unexecuted instantiation: <i16 as serde::de::Deserialize>::deserialize::<_>
Unexecuted instantiation: <i32 as serde::de::Deserialize>::deserialize::<_>
Unexecuted instantiation: <u64 as serde::de::Deserialize>::deserialize::<_>
Unexecuted instantiation: <u16 as serde::de::Deserialize>::deserialize::<_>
Unexecuted instantiation: <u32 as serde::de::Deserialize>::deserialize::<_>
Unexecuted instantiation: <f64 as serde::de::Deserialize>::deserialize::<_>
Unexecuted instantiation: <u8 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: <<i16 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_i8::<_>
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: <<i128 as serde::de::Deserialize>::deserialize::PrimitiveVisitor as serde::de::Visitor>::visit_i128::<_>
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: <<u8 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_i64::<_>
Unexecuted instantiation: <<u128 as serde::de::Deserialize>::deserialize::PrimitiveVisitor as serde::de::Visitor>::visit_u128::<_>
Unexecuted instantiation: <<u16 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_i32::<_>
144
    };
145
146
    (nonzero $primitive:ident $ty:ident : $visit:ident) => {
147
        fn $visit<E>(self, v: $ty) -> Result<Self::Value, E>
148
        where
149
            E: Error,
150
        {
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::NonZeroI128 as serde::de::Deserialize>::deserialize::NonZeroVisitor as serde::de::Visitor>::visit_i128::<_>
Unexecuted instantiation: <<core::num::nonzero::NonZeroU16 as serde::de::Deserialize>::deserialize::NonZeroVisitor as serde::de::Visitor>::visit_u16::<_>
Unexecuted instantiation: <<core::num::nonzero::NonZeroI32 as serde::de::Deserialize>::deserialize::NonZeroVisitor as serde::de::Visitor>::visit_i32::<_>
Unexecuted instantiation: <<core::num::nonzero::NonZeroI8 as serde::de::Deserialize>::deserialize::NonZeroVisitor as serde::de::Visitor>::visit_i8::<_>
Unexecuted instantiation: <<core::num::nonzero::NonZeroU128 as serde::de::Deserialize>::deserialize::NonZeroVisitor as serde::de::Visitor>::visit_u128::<_>
Unexecuted instantiation: <<core::num::nonzero::NonZeroU8 as serde::de::Deserialize>::deserialize::NonZeroVisitor as serde::de::Visitor>::visit_u8::<_>
Unexecuted instantiation: <<core::num::nonzero::NonZeroI16 as serde::de::Deserialize>::deserialize::NonZeroVisitor as serde::de::Visitor>::visit_i16::<_>
Unexecuted instantiation: <<core::num::nonzero::NonZeroU32 as serde::de::Deserialize>::deserialize::NonZeroVisitor as serde::de::Visitor>::visit_u32::<_>
Unexecuted instantiation: <<core::num::nonzero::NonZeroU64 as serde::de::Deserialize>::deserialize::NonZeroVisitor as serde::de::Visitor>::visit_u64::<_>
Unexecuted instantiation: <<core::num::nonzero::NonZeroI64 as serde::de::Deserialize>::deserialize::NonZeroVisitor as serde::de::Visitor>::visit_i64::<_>
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: <<i64 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_u16::<_>
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_u8::<_>
Unexecuted instantiation: <<isize 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_u8::<_>
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_u8::<_>
Unexecuted instantiation: <<u64 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_u8::<_>
Unexecuted instantiation: <<i128 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_u64::<_>
Unexecuted instantiation: <<f32 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_u8::<_>
Unexecuted instantiation: <<f32 as serde::de::Deserialize>::deserialize::PrimitiveVisitor as serde::de::Visitor>::visit_f64::<_>
Unexecuted instantiation: <<u64 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_u32::<_>
Unexecuted instantiation: <<usize 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_u16::<_>
Unexecuted instantiation: <<u64 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_i16::<_>
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_u64::<_>
Unexecuted instantiation: <<f64 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_i16::<_>
Unexecuted instantiation: <<f64 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_u64::<_>
Unexecuted instantiation: <<f64 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_u32::<_>
Unexecuted instantiation: <<i32 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_u8::<_>
Unexecuted instantiation: <<u128 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_i16::<_>
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_u64::<_>
Unexecuted instantiation: <<u16 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_i16::<_>
Unexecuted instantiation: <<i128 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_i8::<_>
Unexecuted instantiation: <<i64 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_u16::<_>
Unexecuted instantiation: <<i128 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_f32::<_>
Unexecuted instantiation: <<f64 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_i8::<_>
Unexecuted instantiation: <<f32 as serde::de::Deserialize>::deserialize::PrimitiveVisitor as serde::de::Visitor>::visit_i32::<_>
169
    };
170
171
    (nonzero $primitive:ident $ty:ident : $visit:ident) => {
172
        fn $visit<E>(self, v: $ty) -> Result<Self::Value, E>
173
        where
174
            E: Error,
175
        {
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::NonZeroIsize as serde::de::Deserialize>::deserialize::NonZeroVisitor as serde::de::Visitor>::visit_i8::<_>
Unexecuted instantiation: <<core::num::nonzero::NonZeroU32 as serde::de::Deserialize>::deserialize::NonZeroVisitor as serde::de::Visitor>::visit_u8::<_>
Unexecuted instantiation: <<core::num::nonzero::NonZeroU64 as serde::de::Deserialize>::deserialize::NonZeroVisitor as serde::de::Visitor>::visit_u16::<_>
Unexecuted instantiation: <<core::num::nonzero::NonZeroI128 as serde::de::Deserialize>::deserialize::NonZeroVisitor as serde::de::Visitor>::visit_u8::<_>
Unexecuted instantiation: <<core::num::nonzero::NonZeroI128 as serde::de::Deserialize>::deserialize::NonZeroVisitor as serde::de::Visitor>::visit_i64::<_>
Unexecuted instantiation: <<core::num::nonzero::NonZeroI128 as serde::de::Deserialize>::deserialize::NonZeroVisitor as serde::de::Visitor>::visit_i32::<_>
Unexecuted instantiation: <<core::num::nonzero::NonZeroU128 as serde::de::Deserialize>::deserialize::NonZeroVisitor as serde::de::Visitor>::visit_u64::<_>
Unexecuted instantiation: <<core::num::nonzero::NonZeroI32 as serde::de::Deserialize>::deserialize::NonZeroVisitor as serde::de::Visitor>::visit_i8::<_>
Unexecuted instantiation: <<core::num::nonzero::NonZeroU128 as serde::de::Deserialize>::deserialize::NonZeroVisitor as serde::de::Visitor>::visit_u32::<_>
Unexecuted instantiation: <<core::num::nonzero::NonZeroI64 as serde::de::Deserialize>::deserialize::NonZeroVisitor as serde::de::Visitor>::visit_i8::<_>
Unexecuted instantiation: <<core::num::nonzero::NonZeroU64 as serde::de::Deserialize>::deserialize::NonZeroVisitor as serde::de::Visitor>::visit_u8::<_>
Unexecuted instantiation: <<core::num::nonzero::NonZeroI64 as serde::de::Deserialize>::deserialize::NonZeroVisitor as serde::de::Visitor>::visit_i16::<_>
Unexecuted instantiation: <<core::num::nonzero::NonZeroI16 as serde::de::Deserialize>::deserialize::NonZeroVisitor as serde::de::Visitor>::visit_i8::<_>
Unexecuted instantiation: <<core::num::nonzero::NonZeroI32 as serde::de::Deserialize>::deserialize::NonZeroVisitor as serde::de::Visitor>::visit_i16::<_>
Unexecuted instantiation: <<core::num::nonzero::NonZeroUsize as serde::de::Deserialize>::deserialize::NonZeroVisitor as serde::de::Visitor>::visit_u8::<_>
Unexecuted instantiation: <<core::num::nonzero::NonZeroU16 as serde::de::Deserialize>::deserialize::NonZeroVisitor as serde::de::Visitor>::visit_u8::<_>
Unexecuted instantiation: <<core::num::nonzero::NonZeroUsize as serde::de::Deserialize>::deserialize::NonZeroVisitor as serde::de::Visitor>::visit_u16::<_>
Unexecuted instantiation: <<core::num::nonzero::NonZeroI128 as serde::de::Deserialize>::deserialize::NonZeroVisitor as serde::de::Visitor>::visit_i8::<_>
Unexecuted instantiation: <<core::num::nonzero::NonZeroU128 as serde::de::Deserialize>::deserialize::NonZeroVisitor as serde::de::Visitor>::visit_u8::<_>
Unexecuted instantiation: <<core::num::nonzero::NonZeroI128 as serde::de::Deserialize>::deserialize::NonZeroVisitor as serde::de::Visitor>::visit_u32::<_>
Unexecuted instantiation: <<core::num::nonzero::NonZeroU64 as serde::de::Deserialize>::deserialize::NonZeroVisitor as serde::de::Visitor>::visit_u32::<_>
Unexecuted instantiation: <<core::num::nonzero::NonZeroIsize as serde::de::Deserialize>::deserialize::NonZeroVisitor as serde::de::Visitor>::visit_i16::<_>
Unexecuted instantiation: <<core::num::nonzero::NonZeroI64 as serde::de::Deserialize>::deserialize::NonZeroVisitor as serde::de::Visitor>::visit_i32::<_>
Unexecuted instantiation: <<core::num::nonzero::NonZeroI128 as serde::de::Deserialize>::deserialize::NonZeroVisitor as serde::de::Visitor>::visit_i16::<_>
Unexecuted instantiation: <<core::num::nonzero::NonZeroI128 as serde::de::Deserialize>::deserialize::NonZeroVisitor as serde::de::Visitor>::visit_u16::<_>
Unexecuted instantiation: <<core::num::nonzero::NonZeroU32 as serde::de::Deserialize>::deserialize::NonZeroVisitor as serde::de::Visitor>::visit_u16::<_>
Unexecuted instantiation: <<core::num::nonzero::NonZeroU128 as serde::de::Deserialize>::deserialize::NonZeroVisitor as serde::de::Visitor>::visit_u16::<_>
Unexecuted instantiation: <<core::num::nonzero::NonZeroI128 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_i32::<_>
Unexecuted instantiation: <<i32 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_i64::<_>
Unexecuted instantiation: <<i8 as serde::de::Deserialize>::deserialize::PrimitiveVisitor as serde::de::Visitor>::visit_i16::<_>
Unexecuted instantiation: <<i16 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::<_>
Unexecuted instantiation: <<isize 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::<_>
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::NonZeroI8 as serde::de::Deserialize>::deserialize::NonZeroVisitor as serde::de::Visitor>::visit_i16::<_>
Unexecuted instantiation: <<core::num::nonzero::NonZeroI32 as serde::de::Deserialize>::deserialize::NonZeroVisitor as serde::de::Visitor>::visit_i64::<_>
Unexecuted instantiation: <<core::num::nonzero::NonZeroI16 as serde::de::Deserialize>::deserialize::NonZeroVisitor as serde::de::Visitor>::visit_i64::<_>
Unexecuted instantiation: <<core::num::nonzero::NonZeroI16 as serde::de::Deserialize>::deserialize::NonZeroVisitor as serde::de::Visitor>::visit_i32::<_>
Unexecuted instantiation: <<core::num::nonzero::NonZeroIsize as serde::de::Deserialize>::deserialize::NonZeroVisitor as serde::de::Visitor>::visit_i64::<_>
Unexecuted instantiation: <<core::num::nonzero::NonZeroI8 as serde::de::Deserialize>::deserialize::NonZeroVisitor as serde::de::Visitor>::visit_i32::<_>
Unexecuted instantiation: <<core::num::nonzero::NonZeroI8 as serde::de::Deserialize>::deserialize::NonZeroVisitor as serde::de::Visitor>::visit_i64::<_>
Unexecuted instantiation: <<core::num::nonzero::NonZeroIsize as serde::de::Deserialize>::deserialize::NonZeroVisitor as serde::de::Visitor>::visit_i32::<_>
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: <<u64 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: <<u128 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_i16::<_>
Unexecuted instantiation: <<u16 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: <<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: <<u32 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_i32::<_>
Unexecuted instantiation: <<usize 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_i32::<_>
Unexecuted instantiation: <<u64 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_i8::<_>
Unexecuted instantiation: <<u16 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_i64::<_>
Unexecuted instantiation: <<usize 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_i16::<_>
Unexecuted instantiation: <<u128 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: <<usize 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: <<u16 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::NonZeroU128 as serde::de::Deserialize>::deserialize::NonZeroVisitor as serde::de::Visitor>::visit_i8::<_>
Unexecuted instantiation: <<core::num::nonzero::NonZeroU8 as serde::de::Deserialize>::deserialize::NonZeroVisitor as serde::de::Visitor>::visit_i16::<_>
Unexecuted instantiation: <<core::num::nonzero::NonZeroU32 as serde::de::Deserialize>::deserialize::NonZeroVisitor as serde::de::Visitor>::visit_i16::<_>
Unexecuted instantiation: <<core::num::nonzero::NonZeroUsize as serde::de::Deserialize>::deserialize::NonZeroVisitor as serde::de::Visitor>::visit_i8::<_>
Unexecuted instantiation: <<core::num::nonzero::NonZeroU8 as serde::de::Deserialize>::deserialize::NonZeroVisitor as serde::de::Visitor>::visit_i32::<_>
Unexecuted instantiation: <<core::num::nonzero::NonZeroU16 as serde::de::Deserialize>::deserialize::NonZeroVisitor as serde::de::Visitor>::visit_i32::<_>
Unexecuted instantiation: <<core::num::nonzero::NonZeroU64 as serde::de::Deserialize>::deserialize::NonZeroVisitor as serde::de::Visitor>::visit_i64::<_>
Unexecuted instantiation: <<core::num::nonzero::NonZeroU8 as serde::de::Deserialize>::deserialize::NonZeroVisitor as serde::de::Visitor>::visit_i8::<_>
Unexecuted instantiation: <<core::num::nonzero::NonZeroU128 as serde::de::Deserialize>::deserialize::NonZeroVisitor as serde::de::Visitor>::visit_i64::<_>
Unexecuted instantiation: <<core::num::nonzero::NonZeroUsize as serde::de::Deserialize>::deserialize::NonZeroVisitor as serde::de::Visitor>::visit_i32::<_>
Unexecuted instantiation: <<core::num::nonzero::NonZeroUsize as serde::de::Deserialize>::deserialize::NonZeroVisitor as serde::de::Visitor>::visit_i64::<_>
Unexecuted instantiation: <<core::num::nonzero::NonZeroU32 as serde::de::Deserialize>::deserialize::NonZeroVisitor as serde::de::Visitor>::visit_i64::<_>
Unexecuted instantiation: <<core::num::nonzero::NonZeroU16 as serde::de::Deserialize>::deserialize::NonZeroVisitor as serde::de::Visitor>::visit_i8::<_>
Unexecuted instantiation: <<core::num::nonzero::NonZeroU16 as serde::de::Deserialize>::deserialize::NonZeroVisitor as serde::de::Visitor>::visit_i16::<_>
Unexecuted instantiation: <<core::num::nonzero::NonZeroU128 as serde::de::Deserialize>::deserialize::NonZeroVisitor as serde::de::Visitor>::visit_i16::<_>
Unexecuted instantiation: <<core::num::nonzero::NonZeroU32 as serde::de::Deserialize>::deserialize::NonZeroVisitor as serde::de::Visitor>::visit_i32::<_>
Unexecuted instantiation: <<core::num::nonzero::NonZeroU32 as serde::de::Deserialize>::deserialize::NonZeroVisitor as serde::de::Visitor>::visit_i8::<_>
Unexecuted instantiation: <<core::num::nonzero::NonZeroU16 as serde::de::Deserialize>::deserialize::NonZeroVisitor as serde::de::Visitor>::visit_i64::<_>
Unexecuted instantiation: <<core::num::nonzero::NonZeroUsize as serde::de::Deserialize>::deserialize::NonZeroVisitor as serde::de::Visitor>::visit_i16::<_>
Unexecuted instantiation: <<core::num::nonzero::NonZeroU64 as serde::de::Deserialize>::deserialize::NonZeroVisitor as serde::de::Visitor>::visit_i32::<_>
Unexecuted instantiation: <<core::num::nonzero::NonZeroU128 as serde::de::Deserialize>::deserialize::NonZeroVisitor as serde::de::Visitor>::visit_i32::<_>
Unexecuted instantiation: <<core::num::nonzero::NonZeroU64 as serde::de::Deserialize>::deserialize::NonZeroVisitor as serde::de::Visitor>::visit_i8::<_>
Unexecuted instantiation: <<core::num::nonzero::NonZeroU8 as serde::de::Deserialize>::deserialize::NonZeroVisitor as serde::de::Visitor>::visit_i64::<_>
Unexecuted instantiation: <<core::num::nonzero::NonZeroU64 as serde::de::Deserialize>::deserialize::NonZeroVisitor as serde::de::Visitor>::visit_i16::<_>
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: <<u8 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_u8::<_>
Unexecuted instantiation: <<i32 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: <<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: <<i16 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_u16::<_>
Unexecuted instantiation: <<isize 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: <<i8 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_u64::<_>
Unexecuted instantiation: <<usize 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: <<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: <<i8 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_u64::<_>
Unexecuted instantiation: <<usize 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_u16::<_>
Unexecuted instantiation: <<u32 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_u64::<_>
Unexecuted instantiation: <<isize 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: <<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_u8::<_>
Unexecuted instantiation: <<isize 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::<_>
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::NonZeroUsize as serde::de::Deserialize>::deserialize::NonZeroVisitor as serde::de::Visitor>::visit_u32::<_>
Unexecuted instantiation: <<core::num::nonzero::NonZeroIsize as serde::de::Deserialize>::deserialize::NonZeroVisitor as serde::de::Visitor>::visit_u16::<_>
Unexecuted instantiation: <<core::num::nonzero::NonZeroI32 as serde::de::Deserialize>::deserialize::NonZeroVisitor as serde::de::Visitor>::visit_u32::<_>
Unexecuted instantiation: <<core::num::nonzero::NonZeroU16 as serde::de::Deserialize>::deserialize::NonZeroVisitor as serde::de::Visitor>::visit_u64::<_>
Unexecuted instantiation: <<core::num::nonzero::NonZeroI16 as serde::de::Deserialize>::deserialize::NonZeroVisitor as serde::de::Visitor>::visit_u64::<_>
Unexecuted instantiation: <<core::num::nonzero::NonZeroI8 as serde::de::Deserialize>::deserialize::NonZeroVisitor as serde::de::Visitor>::visit_u8::<_>
Unexecuted instantiation: <<core::num::nonzero::NonZeroI64 as serde::de::Deserialize>::deserialize::NonZeroVisitor as serde::de::Visitor>::visit_u16::<_>
Unexecuted instantiation: <<core::num::nonzero::NonZeroI32 as serde::de::Deserialize>::deserialize::NonZeroVisitor as serde::de::Visitor>::visit_u64::<_>
Unexecuted instantiation: <<core::num::nonzero::NonZeroI64 as serde::de::Deserialize>::deserialize::NonZeroVisitor as serde::de::Visitor>::visit_u8::<_>
Unexecuted instantiation: <<core::num::nonzero::NonZeroU8 as serde::de::Deserialize>::deserialize::NonZeroVisitor as serde::de::Visitor>::visit_u64::<_>
Unexecuted instantiation: <<core::num::nonzero::NonZeroI32 as serde::de::Deserialize>::deserialize::NonZeroVisitor as serde::de::Visitor>::visit_u8::<_>
Unexecuted instantiation: <<core::num::nonzero::NonZeroU8 as serde::de::Deserialize>::deserialize::NonZeroVisitor as serde::de::Visitor>::visit_u16::<_>
Unexecuted instantiation: <<core::num::nonzero::NonZeroI32 as serde::de::Deserialize>::deserialize::NonZeroVisitor as serde::de::Visitor>::visit_u16::<_>
Unexecuted instantiation: <<core::num::nonzero::NonZeroI8 as serde::de::Deserialize>::deserialize::NonZeroVisitor as serde::de::Visitor>::visit_u32::<_>
Unexecuted instantiation: <<core::num::nonzero::NonZeroIsize as serde::de::Deserialize>::deserialize::NonZeroVisitor as serde::de::Visitor>::visit_u8::<_>
Unexecuted instantiation: <<core::num::nonzero::NonZeroI64 as serde::de::Deserialize>::deserialize::NonZeroVisitor as serde::de::Visitor>::visit_u32::<_>
Unexecuted instantiation: <<core::num::nonzero::NonZeroU16 as serde::de::Deserialize>::deserialize::NonZeroVisitor as serde::de::Visitor>::visit_u32::<_>
Unexecuted instantiation: <<core::num::nonzero::NonZeroI16 as serde::de::Deserialize>::deserialize::NonZeroVisitor as serde::de::Visitor>::visit_u16::<_>
Unexecuted instantiation: <<core::num::nonzero::NonZeroI8 as serde::de::Deserialize>::deserialize::NonZeroVisitor as serde::de::Visitor>::visit_u64::<_>
Unexecuted instantiation: <<core::num::nonzero::NonZeroI64 as serde::de::Deserialize>::deserialize::NonZeroVisitor as serde::de::Visitor>::visit_u64::<_>
Unexecuted instantiation: <<core::num::nonzero::NonZeroI8 as serde::de::Deserialize>::deserialize::NonZeroVisitor as serde::de::Visitor>::visit_u16::<_>
Unexecuted instantiation: <<core::num::nonzero::NonZeroUsize as serde::de::Deserialize>::deserialize::NonZeroVisitor as serde::de::Visitor>::visit_u64::<_>
Unexecuted instantiation: <<core::num::nonzero::NonZeroIsize as serde::de::Deserialize>::deserialize::NonZeroVisitor as serde::de::Visitor>::visit_u32::<_>
Unexecuted instantiation: <<core::num::nonzero::NonZeroI16 as serde::de::Deserialize>::deserialize::NonZeroVisitor as serde::de::Visitor>::visit_u32::<_>
Unexecuted instantiation: <<core::num::nonzero::NonZeroU8 as serde::de::Deserialize>::deserialize::NonZeroVisitor as serde::de::Visitor>::visit_u32::<_>
Unexecuted instantiation: <<core::num::nonzero::NonZeroIsize as serde::de::Deserialize>::deserialize::NonZeroVisitor as serde::de::Visitor>::visit_u64::<_>
Unexecuted instantiation: <<core::num::nonzero::NonZeroI16 as serde::de::Deserialize>::deserialize::NonZeroVisitor as serde::de::Visitor>::visit_u8::<_>
Unexecuted instantiation: <<core::num::nonzero::NonZeroU32 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: <<u128 as serde::de::Deserialize>::deserialize::PrimitiveVisitor as serde::de::Visitor>::visit_i128::<_>
Unexecuted instantiation: <<i128 as serde::de::Deserialize>::deserialize::PrimitiveVisitor as serde::de::Visitor>::visit_u128::<_>
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::NonZeroU128 as serde::de::Deserialize>::deserialize::NonZeroVisitor as serde::de::Visitor>::visit_i128::<_>
Unexecuted instantiation: <<core::num::nonzero::NonZeroI128 as serde::de::Deserialize>::deserialize::NonZeroVisitor as serde::de::Visitor>::visit_u128::<_>
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
    fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
437
        formatter.write_str("a character")
438
    }
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
    fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
483
        formatter.write_str("a string")
484
    }
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
    }
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
    fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
529
        formatter.write_str("a string")
530
    }
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
    }
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
    fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
605
        formatter.write_str("a borrowed string")
606
    }
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
    fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
640
        formatter.write_str("a borrowed byte array")
641
    }
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(any(feature = "std", all(not(no_core_cstr), feature = "alloc")))]
670
struct CStringVisitor;
671
672
#[cfg(any(feature = "std", all(not(no_core_cstr), feature = "alloc")))]
673
impl<'de> Visitor<'de> for CStringVisitor {
674
    type Value = CString;
675
676
    fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
677
        formatter.write_str("byte array")
678
    }
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(any(feature = "std", all(not(no_core_cstr), feature = "alloc")))]
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<std::path::Path> as serde::de::Deserialize>::deserialize::<_>
Unexecuted instantiation: <core::cmp::Reverse<_> as serde::de::Deserialize>::deserialize::<_>
Unexecuted instantiation: <core::cell::RefCell<_> as serde::de::Deserialize>::deserialize::<_>
Unexecuted instantiation: <std::sync::rwlock::RwLock<_> as serde::de::Deserialize>::deserialize::<_>
Unexecuted instantiation: <alloc::boxed::Box<_> as serde::de::Deserialize>::deserialize::<_>
Unexecuted instantiation: <alloc::boxed::Box<core::ffi::c_str::CStr> as serde::de::Deserialize>::deserialize::<_>
Unexecuted instantiation: <alloc::boxed::Box<str> as serde::de::Deserialize>::deserialize::<_>
Unexecuted instantiation: <alloc::boxed::Box<[_]> as serde::de::Deserialize>::deserialize::<_>
Unexecuted instantiation: <std::sync::mutex::Mutex<_> as serde::de::Deserialize>::deserialize::<_>
746
        }
747
    }
748
}
749
750
#[cfg(all(
751
    any(feature = "std", all(not(no_core_cstr), feature = "alloc")),
752
    not(no_de_boxed_c_str)
753
))]
754
forwarded_impl!((), Box<CStr>, CString::into_boxed_c_str);
755
756
#[cfg(not(no_core_reverse))]
757
forwarded_impl!((T), Reverse<T>, Reverse);
758
759
////////////////////////////////////////////////////////////////////////////////
760
761
struct OptionVisitor<T> {
762
    marker: PhantomData<T>,
763
}
764
765
impl<'de, T> Visitor<'de> for OptionVisitor<T>
766
where
767
    T: Deserialize<'de>,
768
{
769
    type Value = Option<T>;
770
771
0
    fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
772
0
        formatter.write_str("option")
773
0
    }
774
775
    #[inline]
776
0
    fn visit_unit<E>(self) -> Result<Self::Value, E>
777
0
    where
778
0
        E: Error,
779
0
    {
780
0
        Ok(None)
781
0
    }
782
783
    #[inline]
784
0
    fn visit_none<E>(self) -> Result<Self::Value, E>
785
0
    where
786
0
        E: Error,
787
0
    {
788
0
        Ok(None)
789
0
    }
790
791
    #[inline]
792
0
    fn visit_some<D>(self, deserializer: D) -> Result<Self::Value, D::Error>
793
0
    where
794
0
        D: Deserializer<'de>,
795
0
    {
796
0
        T::deserialize(deserializer).map(Some)
797
0
    }
798
799
0
    fn __private_visit_untagged_option<D>(self, deserializer: D) -> Result<Self::Value, ()>
800
0
    where
801
0
        D: Deserializer<'de>,
802
0
    {
803
0
        Ok(T::deserialize(deserializer).ok())
804
0
    }
805
}
806
807
impl<'de, T> Deserialize<'de> for Option<T>
808
where
809
    T: Deserialize<'de>,
810
{
811
0
    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
812
0
    where
813
0
        D: Deserializer<'de>,
814
0
    {
815
0
        deserializer.deserialize_option(OptionVisitor {
816
0
            marker: PhantomData,
817
0
        })
818
0
    }
819
820
    // The Some variant's repr is opaque, so we can't play cute tricks with its
821
    // tag to have deserialize_in_place build the content in place unconditionally.
822
    //
823
    // FIXME: investigate whether branching on the old value being Some to
824
    // deserialize_in_place the value is profitable (probably data-dependent?)
825
}
826
827
////////////////////////////////////////////////////////////////////////////////
828
829
struct PhantomDataVisitor<T: ?Sized> {
830
    marker: PhantomData<T>,
831
}
832
833
impl<'de, T: ?Sized> Visitor<'de> for PhantomDataVisitor<T> {
834
    type Value = PhantomData<T>;
835
836
0
    fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
837
0
        formatter.write_str("unit")
838
0
    }
839
840
    #[inline]
841
0
    fn visit_unit<E>(self) -> Result<Self::Value, E>
842
0
    where
843
0
        E: Error,
844
0
    {
845
0
        Ok(PhantomData)
846
0
    }
847
}
848
849
impl<'de, T: ?Sized> Deserialize<'de> for PhantomData<T> {
850
0
    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
851
0
    where
852
0
        D: Deserializer<'de>,
853
0
    {
854
0
        let visitor = PhantomDataVisitor {
855
0
            marker: PhantomData,
856
0
        };
857
0
        deserializer.deserialize_unit_struct("PhantomData", visitor)
858
0
    }
859
}
860
861
////////////////////////////////////////////////////////////////////////////////
862
863
#[cfg(any(feature = "std", feature = "alloc"))]
864
macro_rules! seq_impl {
865
    (
866
        $ty:ident <T $(: $tbound1:ident $(+ $tbound2:ident)*)* $(, $typaram:ident : $bound1:ident $(+ $bound2:ident)*)*>,
867
        $access:ident,
868
        $clear:expr,
869
        $with_capacity:expr,
870
        $reserve:expr,
871
        $insert:expr
872
    ) => {
873
        impl<'de, T $(, $typaram)*> Deserialize<'de> for $ty<T $(, $typaram)*>
874
        where
875
            T: Deserialize<'de> $(+ $tbound1 $(+ $tbound2)*)*,
876
            $($typaram: $bound1 $(+ $bound2)*,)*
877
        {
878
0
            fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
879
0
            where
880
0
                D: Deserializer<'de>,
881
0
            {
882
0
                struct SeqVisitor<T $(, $typaram)*> {
883
0
                    marker: PhantomData<$ty<T $(, $typaram)*>>,
884
0
                }
885
0
886
0
                impl<'de, T $(, $typaram)*> Visitor<'de> for SeqVisitor<T $(, $typaram)*>
887
0
                where
888
0
                    T: Deserialize<'de> $(+ $tbound1 $(+ $tbound2)*)*,
889
0
                    $($typaram: $bound1 $(+ $bound2)*,)*
890
0
                {
891
0
                    type Value = $ty<T $(, $typaram)*>;
892
0
893
0
                    fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
894
0
                        formatter.write_str("a sequence")
895
0
                    }
Unexecuted instantiation: <<alloc::collections::vec_deque::VecDeque<_> 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::btree::set::BTreeSet<_> as serde::de::Deserialize>::deserialize::SeqVisitor<_> as serde::de::Visitor>::expecting
Unexecuted instantiation: <<alloc::collections::binary_heap::BinaryHeap<_> 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
896
0
897
0
                    #[inline]
898
0
                    fn visit_seq<A>(self, mut $access: A) -> Result<Self::Value, A::Error>
899
0
                    where
900
0
                        A: SeqAccess<'de>,
901
0
                    {
902
0
                        let mut values = $with_capacity;
903
0
904
0
                        while let Some(value) = try!($access.next_element()) {
905
0
                            $insert(&mut values, value);
906
0
                        }
907
0
908
0
                        Ok(values)
909
0
                    }
Unexecuted instantiation: <<alloc::collections::binary_heap::BinaryHeap<_> 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::<_>
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::<_>
910
0
                }
911
0
912
0
                let visitor = SeqVisitor { marker: PhantomData };
913
0
                deserializer.deserialize_seq(visitor)
914
0
            }
Unexecuted instantiation: <alloc::collections::btree::set::BTreeSet<_> as serde::de::Deserialize>::deserialize::<_>
Unexecuted instantiation: <alloc::collections::binary_heap::BinaryHeap<_> as serde::de::Deserialize>::deserialize::<_>
Unexecuted instantiation: <alloc::collections::vec_deque::VecDeque<_> as serde::de::Deserialize>::deserialize::<_>
Unexecuted instantiation: <std::collections::hash::set::HashSet<_, _> as serde::de::Deserialize>::deserialize::<_>
Unexecuted instantiation: <alloc::collections::linked_list::LinkedList<_> as serde::de::Deserialize>::deserialize::<_>
915
916
0
            fn deserialize_in_place<D>(deserializer: D, place: &mut Self) -> Result<(), D::Error>
917
0
            where
918
0
                D: Deserializer<'de>,
919
0
            {
920
0
                struct SeqInPlaceVisitor<'a, T: 'a $(, $typaram: 'a)*>(&'a mut $ty<T $(, $typaram)*>);
921
0
922
0
                impl<'a, 'de, T $(, $typaram)*> Visitor<'de> for SeqInPlaceVisitor<'a, T $(, $typaram)*>
923
0
                where
924
0
                    T: Deserialize<'de> $(+ $tbound1 $(+ $tbound2)*)*,
925
0
                    $($typaram: $bound1 $(+ $bound2)*,)*
926
0
                {
927
0
                    type Value = ();
928
0
929
0
                    fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
930
0
                        formatter.write_str("a sequence")
931
0
                    }
Unexecuted instantiation: <<alloc::collections::vec_deque::VecDeque<_> 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::binary_heap::BinaryHeap<_> 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: <<alloc::collections::btree::set::BTreeSet<_> as serde::de::Deserialize>::deserialize_in_place::SeqInPlaceVisitor<_> as serde::de::Visitor>::expecting
932
0
933
0
                    #[inline]
934
0
                    fn visit_seq<A>(mut self, mut $access: A) -> Result<Self::Value, A::Error>
935
0
                    where
936
0
                        A: SeqAccess<'de>,
937
0
                    {
938
0
                        $clear(&mut self.0);
939
0
                        $reserve(&mut self.0, size_hint::cautious($access.size_hint()));
940
0
941
0
                        // FIXME: try to overwrite old values here? (Vec, VecDeque, LinkedList)
942
0
                        while let Some(value) = try!($access.next_element()) {
943
0
                            $insert(&mut self.0, value);
944
0
                        }
945
0
946
0
                        Ok(())
947
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::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::btree::set::BTreeSet<_> 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::<_>
948
0
                }
949
0
950
0
                deserializer.deserialize_seq(SeqInPlaceVisitor(place))
951
0
            }
Unexecuted instantiation: <alloc::collections::binary_heap::BinaryHeap<_> as serde::de::Deserialize>::deserialize_in_place::<_>
Unexecuted instantiation: <alloc::collections::vec_deque::VecDeque<_> 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::btree::set::BTreeSet<_> as serde::de::Deserialize>::deserialize_in_place::<_>
952
        }
953
    }
954
}
955
956
// Dummy impl of reserve
957
#[cfg(any(feature = "std", feature = "alloc"))]
958
0
fn nop_reserve<T>(_seq: T, _n: usize) {}
959
960
#[cfg(any(feature = "std", feature = "alloc"))]
961
seq_impl!(
962
    BinaryHeap<T: Ord>,
963
    seq,
964
    BinaryHeap::clear,
965
    BinaryHeap::with_capacity(size_hint::cautious(seq.size_hint())),
966
    BinaryHeap::reserve,
967
    BinaryHeap::push
968
);
969
970
#[cfg(any(feature = "std", feature = "alloc"))]
971
seq_impl!(
972
    BTreeSet<T: Eq + Ord>,
973
    seq,
974
    BTreeSet::clear,
975
    BTreeSet::new(),
976
    nop_reserve,
977
    BTreeSet::insert
978
);
979
980
#[cfg(any(feature = "std", feature = "alloc"))]
981
seq_impl!(
982
    LinkedList<T>,
983
    seq,
984
    LinkedList::clear,
985
    LinkedList::new(),
986
    nop_reserve,
987
    LinkedList::push_back
988
);
989
990
#[cfg(feature = "std")]
991
seq_impl!(
992
    HashSet<T: Eq + Hash, S: BuildHasher + Default>,
993
    seq,
994
    HashSet::clear,
995
    HashSet::with_capacity_and_hasher(size_hint::cautious(seq.size_hint()), S::default()),
996
    HashSet::reserve,
997
    HashSet::insert);
998
999
#[cfg(any(feature = "std", feature = "alloc"))]
1000
seq_impl!(
1001
    VecDeque<T>,
1002
    seq,
1003
    VecDeque::clear,
1004
    VecDeque::with_capacity(size_hint::cautious(seq.size_hint())),
1005
    VecDeque::reserve,
1006
    VecDeque::push_back
1007
);
1008
1009
////////////////////////////////////////////////////////////////////////////////
1010
1011
#[cfg(any(feature = "std", feature = "alloc"))]
1012
impl<'de, T> Deserialize<'de> for Vec<T>
1013
where
1014
    T: Deserialize<'de>,
1015
{
1016
0
    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
1017
0
    where
1018
0
        D: Deserializer<'de>,
1019
0
    {
1020
0
        struct VecVisitor<T> {
1021
0
            marker: PhantomData<T>,
1022
0
        }
1023
0
1024
0
        impl<'de, T> Visitor<'de> for VecVisitor<T>
1025
0
        where
1026
0
            T: Deserialize<'de>,
1027
0
        {
1028
0
            type Value = Vec<T>;
1029
0
1030
0
            fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
1031
0
                formatter.write_str("a sequence")
1032
0
            }
1033
0
1034
0
            fn visit_seq<A>(self, mut seq: A) -> Result<Self::Value, A::Error>
1035
0
            where
1036
0
                A: SeqAccess<'de>,
1037
0
            {
1038
0
                let mut values = Vec::with_capacity(size_hint::cautious(seq.size_hint()));
1039
0
1040
0
                while let Some(value) = try!(seq.next_element()) {
1041
0
                    values.push(value);
1042
0
                }
1043
0
1044
0
                Ok(values)
1045
0
            }
1046
0
        }
1047
0
1048
0
        let visitor = VecVisitor {
1049
0
            marker: PhantomData,
1050
0
        };
1051
0
        deserializer.deserialize_seq(visitor)
1052
0
    }
1053
1054
0
    fn deserialize_in_place<D>(deserializer: D, place: &mut Self) -> Result<(), D::Error>
1055
0
    where
1056
0
        D: Deserializer<'de>,
1057
0
    {
1058
0
        struct VecInPlaceVisitor<'a, T: 'a>(&'a mut Vec<T>);
1059
0
1060
0
        impl<'a, 'de, T> Visitor<'de> for VecInPlaceVisitor<'a, T>
1061
0
        where
1062
0
            T: Deserialize<'de>,
1063
0
        {
1064
0
            type Value = ();
1065
0
1066
0
            fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
1067
0
                formatter.write_str("a sequence")
1068
0
            }
1069
0
1070
0
            fn visit_seq<A>(self, mut seq: A) -> Result<Self::Value, A::Error>
1071
0
            where
1072
0
                A: SeqAccess<'de>,
1073
0
            {
1074
0
                let hint = size_hint::cautious(seq.size_hint());
1075
0
                if let Some(additional) = hint.checked_sub(self.0.len()) {
1076
0
                    self.0.reserve(additional);
1077
0
                }
1078
0
1079
0
                for i in 0..self.0.len() {
1080
0
                    let next = {
1081
0
                        let next_place = InPlaceSeed(&mut self.0[i]);
1082
0
                        try!(seq.next_element_seed(next_place))
1083
0
                    };
1084
0
                    if next.is_none() {
1085
0
                        self.0.truncate(i);
1086
0
                        return Ok(());
1087
0
                    }
1088
0
                }
1089
0
1090
0
                while let Some(value) = try!(seq.next_element()) {
1091
0
                    self.0.push(value);
1092
0
                }
1093
0
1094
0
                Ok(())
1095
0
            }
1096
0
        }
1097
0
1098
0
        deserializer.deserialize_seq(VecInPlaceVisitor(place))
1099
0
    }
1100
}
1101
1102
////////////////////////////////////////////////////////////////////////////////
1103
1104
struct ArrayVisitor<A> {
1105
    marker: PhantomData<A>,
1106
}
1107
struct ArrayInPlaceVisitor<'a, A: 'a>(&'a mut A);
1108
1109
impl<A> ArrayVisitor<A> {
1110
0
    fn new() -> Self {
1111
0
        ArrayVisitor {
1112
0
            marker: PhantomData,
1113
0
        }
1114
0
    }
1115
}
1116
1117
impl<'de, T> Visitor<'de> for ArrayVisitor<[T; 0]> {
1118
    type Value = [T; 0];
1119
1120
0
    fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
1121
0
        formatter.write_str("an empty array")
1122
0
    }
1123
1124
    #[inline]
1125
0
    fn visit_seq<A>(self, _: A) -> Result<Self::Value, A::Error>
1126
0
    where
1127
0
        A: SeqAccess<'de>,
1128
0
    {
1129
0
        Ok([])
1130
0
    }
1131
}
1132
1133
// Does not require T: Deserialize<'de>.
1134
impl<'de, T> Deserialize<'de> for [T; 0] {
1135
0
    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
1136
0
    where
1137
0
        D: Deserializer<'de>,
1138
0
    {
1139
0
        deserializer.deserialize_tuple(0, ArrayVisitor::<[T; 0]>::new())
1140
0
    }
1141
}
1142
1143
macro_rules! array_impls {
1144
    ($($len:expr => ($($n:tt)+))+) => {
1145
        $(
1146
            impl<'de, T> Visitor<'de> for ArrayVisitor<[T; $len]>
1147
            where
1148
                T: Deserialize<'de>,
1149
            {
1150
                type Value = [T; $len];
1151
1152
0
                fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
1153
0
                    formatter.write_str(concat!("an array of length ", $len))
1154
0
                }
Unexecuted instantiation: <serde::de::impls::ArrayVisitor<[_; 16]> as serde::de::Visitor>::expecting
Unexecuted instantiation: <serde::de::impls::ArrayVisitor<[_; 27]> as serde::de::Visitor>::expecting
Unexecuted instantiation: <serde::de::impls::ArrayVisitor<[_; 11]> as serde::de::Visitor>::expecting
Unexecuted instantiation: <serde::de::impls::ArrayVisitor<[_; 17]> as serde::de::Visitor>::expecting
Unexecuted instantiation: <serde::de::impls::ArrayVisitor<[_; 9]> as serde::de::Visitor>::expecting
Unexecuted instantiation: <serde::de::impls::ArrayVisitor<[_; 23]> 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<[_; 20]> as serde::de::Visitor>::expecting
Unexecuted instantiation: <serde::de::impls::ArrayVisitor<[_; 22]> as serde::de::Visitor>::expecting
Unexecuted instantiation: <serde::de::impls::ArrayVisitor<[_; 25]> as serde::de::Visitor>::expecting
Unexecuted instantiation: <serde::de::impls::ArrayVisitor<[_; 7]> as serde::de::Visitor>::expecting
Unexecuted instantiation: <serde::de::impls::ArrayVisitor<[_; 26]> as serde::de::Visitor>::expecting
Unexecuted instantiation: <serde::de::impls::ArrayVisitor<[_; 32]> 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<[_; 8]> as serde::de::Visitor>::expecting
Unexecuted instantiation: <serde::de::impls::ArrayVisitor<[_; 19]> as serde::de::Visitor>::expecting
Unexecuted instantiation: <serde::de::impls::ArrayVisitor<[_; 10]> 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<[_; 21]> 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<[_; 6]> as serde::de::Visitor>::expecting
Unexecuted instantiation: <serde::de::impls::ArrayVisitor<[_; 3]> as serde::de::Visitor>::expecting
Unexecuted instantiation: <serde::de::impls::ArrayVisitor<[_; 18]> as serde::de::Visitor>::expecting
Unexecuted instantiation: <serde::de::impls::ArrayVisitor<[_; 12]> as serde::de::Visitor>::expecting
Unexecuted instantiation: <serde::de::impls::ArrayVisitor<[_; 1]> as serde::de::Visitor>::expecting
Unexecuted instantiation: <serde::de::impls::ArrayVisitor<[_; 24]> as serde::de::Visitor>::expecting
Unexecuted instantiation: <serde::de::impls::ArrayVisitor<[_; 2]> as serde::de::Visitor>::expecting
1155
1156
                #[inline]
1157
0
                fn visit_seq<A>(self, mut seq: A) -> Result<Self::Value, A::Error>
1158
0
                where
1159
0
                    A: SeqAccess<'de>,
1160
0
                {
1161
                    Ok([$(
1162
0
                        match try!(seq.next_element()) {
1163
0
                            Some(val) => val,
1164
0
                            None => return Err(Error::invalid_length($n, &self)),
1165
                        }
1166
                    ),+])
1167
0
                }
Unexecuted instantiation: <serde::de::impls::ArrayVisitor<[_; 13]> 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<[_; 1]> 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<[_; 6]> 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<[_; 30]> 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<[_; 18]> 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<[_; 9]> 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<[_; 26]> 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<[_; 10]> 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<[_; 17]> 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<[_; 8]> 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<[_; 3]> as serde::de::Visitor>::visit_seq::<_>
Unexecuted instantiation: <serde::de::impls::ArrayVisitor<[_; 32]> 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<[_; 23]> 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<[_; 31]> 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<[_; 16]> 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<[_; 29]> 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<[_; 4]> as serde::de::Visitor>::visit_seq::<_>
1168
            }
1169
1170
            impl<'a, 'de, T> Visitor<'de> for ArrayInPlaceVisitor<'a, [T; $len]>
1171
            where
1172
                T: Deserialize<'de>,
1173
            {
1174
                type Value = ();
1175
1176
0
                fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
1177
0
                    formatter.write_str(concat!("an array of length ", $len))
1178
0
                }
Unexecuted instantiation: <serde::de::impls::ArrayInPlaceVisitor<[_; 30]> as serde::de::Visitor>::expecting
Unexecuted instantiation: <serde::de::impls::ArrayInPlaceVisitor<[_; 11]> as serde::de::Visitor>::expecting
Unexecuted instantiation: <serde::de::impls::ArrayInPlaceVisitor<[_; 2]> as serde::de::Visitor>::expecting
Unexecuted instantiation: <serde::de::impls::ArrayInPlaceVisitor<[_; 29]> as serde::de::Visitor>::expecting
Unexecuted instantiation: <serde::de::impls::ArrayInPlaceVisitor<[_; 16]> as serde::de::Visitor>::expecting
Unexecuted instantiation: <serde::de::impls::ArrayInPlaceVisitor<[_; 3]> as serde::de::Visitor>::expecting
Unexecuted instantiation: <serde::de::impls::ArrayInPlaceVisitor<[_; 8]> as serde::de::Visitor>::expecting
Unexecuted instantiation: <serde::de::impls::ArrayInPlaceVisitor<[_; 19]> as serde::de::Visitor>::expecting
Unexecuted instantiation: <serde::de::impls::ArrayInPlaceVisitor<[_; 14]> as serde::de::Visitor>::expecting
Unexecuted instantiation: <serde::de::impls::ArrayInPlaceVisitor<[_; 6]> as serde::de::Visitor>::expecting
Unexecuted instantiation: <serde::de::impls::ArrayInPlaceVisitor<[_; 17]> as serde::de::Visitor>::expecting
Unexecuted instantiation: <serde::de::impls::ArrayInPlaceVisitor<[_; 27]> as serde::de::Visitor>::expecting
Unexecuted instantiation: <serde::de::impls::ArrayInPlaceVisitor<[_; 24]> as serde::de::Visitor>::expecting
Unexecuted instantiation: <serde::de::impls::ArrayInPlaceVisitor<[_; 13]> as serde::de::Visitor>::expecting
Unexecuted instantiation: <serde::de::impls::ArrayInPlaceVisitor<[_; 26]> as serde::de::Visitor>::expecting
Unexecuted instantiation: <serde::de::impls::ArrayInPlaceVisitor<[_; 28]> as serde::de::Visitor>::expecting
Unexecuted instantiation: <serde::de::impls::ArrayInPlaceVisitor<[_; 32]> as serde::de::Visitor>::expecting
Unexecuted instantiation: <serde::de::impls::ArrayInPlaceVisitor<[_; 23]> as serde::de::Visitor>::expecting
Unexecuted instantiation: <serde::de::impls::ArrayInPlaceVisitor<[_; 7]> 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<[_; 1]> as serde::de::Visitor>::expecting
Unexecuted instantiation: <serde::de::impls::ArrayInPlaceVisitor<[_; 15]> as serde::de::Visitor>::expecting
Unexecuted instantiation: <serde::de::impls::ArrayInPlaceVisitor<[_; 5]> as serde::de::Visitor>::expecting
Unexecuted instantiation: <serde::de::impls::ArrayInPlaceVisitor<[_; 18]> as serde::de::Visitor>::expecting
Unexecuted instantiation: <serde::de::impls::ArrayInPlaceVisitor<[_; 20]> as serde::de::Visitor>::expecting
Unexecuted instantiation: <serde::de::impls::ArrayInPlaceVisitor<[_; 4]> as serde::de::Visitor>::expecting
Unexecuted instantiation: <serde::de::impls::ArrayInPlaceVisitor<[_; 31]> as serde::de::Visitor>::expecting
Unexecuted instantiation: <serde::de::impls::ArrayInPlaceVisitor<[_; 22]> as serde::de::Visitor>::expecting
Unexecuted instantiation: <serde::de::impls::ArrayInPlaceVisitor<[_; 21]> as serde::de::Visitor>::expecting
Unexecuted instantiation: <serde::de::impls::ArrayInPlaceVisitor<[_; 25]> as serde::de::Visitor>::expecting
Unexecuted instantiation: <serde::de::impls::ArrayInPlaceVisitor<[_; 12]> as serde::de::Visitor>::expecting
1179
1180
                #[inline]
1181
0
                fn visit_seq<A>(self, mut seq: A) -> Result<Self::Value, A::Error>
1182
0
                where
1183
0
                    A: SeqAccess<'de>,
1184
0
                {
1185
0
                    let mut fail_idx = None;
1186
0
                    for (idx, dest) in self.0[..].iter_mut().enumerate() {
1187
0
                        if try!(seq.next_element_seed(InPlaceSeed(dest))).is_none() {
1188
0
                            fail_idx = Some(idx);
1189
0
                            break;
1190
0
                        }
1191
                    }
1192
0
                    if let Some(idx) = fail_idx {
1193
0
                        return Err(Error::invalid_length(idx, &self));
1194
0
                    }
1195
0
                    Ok(())
1196
0
                }
Unexecuted instantiation: <serde::de::impls::ArrayInPlaceVisitor<[_; 20]> 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<[_; 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<[_; 29]> 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<[_; 16]> 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<[_; 21]> 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::<_>
Unexecuted instantiation: <serde::de::impls::ArrayInPlaceVisitor<[_; 19]> 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<[_; 23]> 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<[_; 28]> 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<[_; 26]> 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<[_; 11]> 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<[_; 8]> as serde::de::Visitor>::visit_seq::<_>
Unexecuted instantiation: <serde::de::impls::ArrayInPlaceVisitor<[_; 1]> 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<[_; 18]> 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<[_; 13]> 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<[_; 17]> 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::<_>
1197
            }
1198
1199
            impl<'de, T> Deserialize<'de> for [T; $len]
1200
            where
1201
                T: Deserialize<'de>,
1202
            {
1203
0
                fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
1204
0
                where
1205
0
                    D: Deserializer<'de>,
1206
0
                {
1207
0
                    deserializer.deserialize_tuple($len, ArrayVisitor::<[T; $len]>::new())
1208
0
                }
Unexecuted instantiation: <[_; 14] as serde::de::Deserialize>::deserialize::<_>
Unexecuted instantiation: <[_; 5] as serde::de::Deserialize>::deserialize::<_>
Unexecuted instantiation: <[_; 17] as serde::de::Deserialize>::deserialize::<_>
Unexecuted instantiation: <[_; 20] as serde::de::Deserialize>::deserialize::<_>
Unexecuted instantiation: <[_; 19] as serde::de::Deserialize>::deserialize::<_>
Unexecuted instantiation: <[_; 18] as serde::de::Deserialize>::deserialize::<_>
Unexecuted instantiation: <[_; 24] as serde::de::Deserialize>::deserialize::<_>
Unexecuted instantiation: <[_; 8] as serde::de::Deserialize>::deserialize::<_>
Unexecuted instantiation: <[_; 23] as serde::de::Deserialize>::deserialize::<_>
Unexecuted instantiation: <[_; 29] as serde::de::Deserialize>::deserialize::<_>
Unexecuted instantiation: <[_; 13] as serde::de::Deserialize>::deserialize::<_>
Unexecuted instantiation: <[_; 28] as serde::de::Deserialize>::deserialize::<_>
Unexecuted instantiation: <[_; 1] as serde::de::Deserialize>::deserialize::<_>
Unexecuted instantiation: <[_; 4] as serde::de::Deserialize>::deserialize::<_>
Unexecuted instantiation: <[_; 3] as serde::de::Deserialize>::deserialize::<_>
Unexecuted instantiation: <[_; 7] as serde::de::Deserialize>::deserialize::<_>
Unexecuted instantiation: <[_; 22] as serde::de::Deserialize>::deserialize::<_>
Unexecuted instantiation: <[_; 25] as serde::de::Deserialize>::deserialize::<_>
Unexecuted instantiation: <[_; 6] as serde::de::Deserialize>::deserialize::<_>
Unexecuted instantiation: <[_; 27] as serde::de::Deserialize>::deserialize::<_>
Unexecuted instantiation: <[_; 9] as serde::de::Deserialize>::deserialize::<_>
Unexecuted instantiation: <[_; 12] as serde::de::Deserialize>::deserialize::<_>
Unexecuted instantiation: <[_; 11] as serde::de::Deserialize>::deserialize::<_>
Unexecuted instantiation: <[_; 26] as serde::de::Deserialize>::deserialize::<_>
Unexecuted instantiation: <[_; 32] as serde::de::Deserialize>::deserialize::<_>
Unexecuted instantiation: <[_; 2] as serde::de::Deserialize>::deserialize::<_>
Unexecuted instantiation: <[_; 16] as serde::de::Deserialize>::deserialize::<_>
Unexecuted instantiation: <[_; 31] as serde::de::Deserialize>::deserialize::<_>
Unexecuted instantiation: <[_; 21] as serde::de::Deserialize>::deserialize::<_>
Unexecuted instantiation: <[_; 10] as serde::de::Deserialize>::deserialize::<_>
Unexecuted instantiation: <[_; 15] as serde::de::Deserialize>::deserialize::<_>
Unexecuted instantiation: <[_; 30] as serde::de::Deserialize>::deserialize::<_>
1209
1210
0
                fn deserialize_in_place<D>(deserializer: D, place: &mut Self) -> Result<(), D::Error>
1211
0
                where
1212
0
                    D: Deserializer<'de>,
1213
0
                {
1214
0
                    deserializer.deserialize_tuple($len, ArrayInPlaceVisitor(place))
1215
0
                }
Unexecuted instantiation: <[_; 13] as serde::de::Deserialize>::deserialize_in_place::<_>
Unexecuted instantiation: <[_; 16] as serde::de::Deserialize>::deserialize_in_place::<_>
Unexecuted instantiation: <[_; 19] as serde::de::Deserialize>::deserialize_in_place::<_>
Unexecuted instantiation: <[_; 3] as serde::de::Deserialize>::deserialize_in_place::<_>
Unexecuted instantiation: <[_; 10] as serde::de::Deserialize>::deserialize_in_place::<_>
Unexecuted instantiation: <[_; 27] as serde::de::Deserialize>::deserialize_in_place::<_>
Unexecuted instantiation: <[_; 15] as serde::de::Deserialize>::deserialize_in_place::<_>
Unexecuted instantiation: <[_; 17] as serde::de::Deserialize>::deserialize_in_place::<_>
Unexecuted instantiation: <[_; 1] as serde::de::Deserialize>::deserialize_in_place::<_>
Unexecuted instantiation: <[_; 28] as serde::de::Deserialize>::deserialize_in_place::<_>
Unexecuted instantiation: <[_; 30] as serde::de::Deserialize>::deserialize_in_place::<_>
Unexecuted instantiation: <[_; 20] as serde::de::Deserialize>::deserialize_in_place::<_>
Unexecuted instantiation: <[_; 22] as serde::de::Deserialize>::deserialize_in_place::<_>
Unexecuted instantiation: <[_; 4] as serde::de::Deserialize>::deserialize_in_place::<_>
Unexecuted instantiation: <[_; 6] as serde::de::Deserialize>::deserialize_in_place::<_>
Unexecuted instantiation: <[_; 18] as serde::de::Deserialize>::deserialize_in_place::<_>
Unexecuted instantiation: <[_; 21] as serde::de::Deserialize>::deserialize_in_place::<_>
Unexecuted instantiation: <[_; 24] as serde::de::Deserialize>::deserialize_in_place::<_>
Unexecuted instantiation: <[_; 8] as serde::de::Deserialize>::deserialize_in_place::<_>
Unexecuted instantiation: <[_; 11] as serde::de::Deserialize>::deserialize_in_place::<_>
Unexecuted instantiation: <[_; 23] as serde::de::Deserialize>::deserialize_in_place::<_>
Unexecuted instantiation: <[_; 25] as serde::de::Deserialize>::deserialize_in_place::<_>
Unexecuted instantiation: <[_; 29] as serde::de::Deserialize>::deserialize_in_place::<_>
Unexecuted instantiation: <[_; 32] as serde::de::Deserialize>::deserialize_in_place::<_>
Unexecuted instantiation: <[_; 2] as serde::de::Deserialize>::deserialize_in_place::<_>
Unexecuted instantiation: <[_; 5] as serde::de::Deserialize>::deserialize_in_place::<_>
Unexecuted instantiation: <[_; 31] as serde::de::Deserialize>::deserialize_in_place::<_>
Unexecuted instantiation: <[_; 7] as serde::de::Deserialize>::deserialize_in_place::<_>
Unexecuted instantiation: <[_; 9] as serde::de::Deserialize>::deserialize_in_place::<_>
Unexecuted instantiation: <[_; 12] as serde::de::Deserialize>::deserialize_in_place::<_>
Unexecuted instantiation: <[_; 14] as serde::de::Deserialize>::deserialize_in_place::<_>
Unexecuted instantiation: <[_; 26] as serde::de::Deserialize>::deserialize_in_place::<_>
1216
            }
1217
        )+
1218
    }
1219
}
1220
1221
array_impls! {
1222
    1 => (0)
1223
    2 => (0 1)
1224
    3 => (0 1 2)
1225
    4 => (0 1 2 3)
1226
    5 => (0 1 2 3 4)
1227
    6 => (0 1 2 3 4 5)
1228
    7 => (0 1 2 3 4 5 6)
1229
    8 => (0 1 2 3 4 5 6 7)
1230
    9 => (0 1 2 3 4 5 6 7 8)
1231
    10 => (0 1 2 3 4 5 6 7 8 9)
1232
    11 => (0 1 2 3 4 5 6 7 8 9 10)
1233
    12 => (0 1 2 3 4 5 6 7 8 9 10 11)
1234
    13 => (0 1 2 3 4 5 6 7 8 9 10 11 12)
1235
    14 => (0 1 2 3 4 5 6 7 8 9 10 11 12 13)
1236
    15 => (0 1 2 3 4 5 6 7 8 9 10 11 12 13 14)
1237
    16 => (0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15)
1238
    17 => (0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16)
1239
    18 => (0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17)
1240
    19 => (0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18)
1241
    20 => (0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19)
1242
    21 => (0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20)
1243
    22 => (0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21)
1244
    23 => (0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22)
1245
    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)
1246
    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)
1247
    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)
1248
    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)
1249
    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)
1250
    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)
1251
    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)
1252
    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)
1253
    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)
1254
}
1255
1256
////////////////////////////////////////////////////////////////////////////////
1257
1258
macro_rules! tuple_impls {
1259
    ($($len:tt => ($($n:tt $name:ident)+))+) => {
1260
        $(
1261
            impl<'de, $($name: Deserialize<'de>),+> Deserialize<'de> for ($($name,)+) {
1262
                #[inline]
1263
0
                fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
1264
0
                where
1265
0
                    D: Deserializer<'de>,
1266
0
                {
1267
0
                    struct TupleVisitor<$($name,)+> {
1268
0
                        marker: PhantomData<($($name,)+)>,
1269
0
                    }
1270
0
1271
0
                    impl<'de, $($name: Deserialize<'de>),+> Visitor<'de> for TupleVisitor<$($name,)+> {
1272
0
                        type Value = ($($name,)+);
1273
0
1274
0
                        fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
1275
0
                            formatter.write_str(concat!("a tuple of size ", $len))
1276
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
1277
0
1278
0
                        #[inline]
1279
0
                        #[allow(non_snake_case)]
1280
0
                        fn visit_seq<A>(self, mut seq: A) -> Result<Self::Value, A::Error>
1281
0
                        where
1282
0
                            A: SeqAccess<'de>,
1283
0
                        {
1284
0
                            $(
1285
0
                                let $name = match try!(seq.next_element()) {
1286
0
                                    Some(value) => value,
1287
0
                                    None => return Err(Error::invalid_length($n, &self)),
1288
0
                                };
1289
0
                            )+
1290
0
1291
0
                            Ok(($($name,)+))
1292
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::<_>
1293
0
                    }
1294
0
1295
0
                    deserializer.deserialize_tuple($len, TupleVisitor { marker: PhantomData })
1296
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::<_>
1297
1298
                #[inline]
1299
0
                fn deserialize_in_place<D>(deserializer: D, place: &mut Self) -> Result<(), D::Error>
1300
0
                where
1301
0
                    D: Deserializer<'de>,
1302
0
                {
1303
0
                    struct TupleInPlaceVisitor<'a, $($name: 'a,)+>(&'a mut ($($name,)+));
1304
0
1305
0
                    impl<'a, 'de, $($name: Deserialize<'de>),+> Visitor<'de> for TupleInPlaceVisitor<'a, $($name,)+> {
1306
0
                        type Value = ();
1307
0
1308
0
                        fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
1309
0
                            formatter.write_str(concat!("a tuple of size ", $len))
1310
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
1311
0
1312
0
                        #[inline]
1313
0
                        #[allow(non_snake_case)]
1314
0
                        fn visit_seq<A>(self, mut seq: A) -> Result<Self::Value, A::Error>
1315
0
                        where
1316
0
                            A: SeqAccess<'de>,
1317
0
                        {
1318
0
                            $(
1319
0
                                if try!(seq.next_element_seed(InPlaceSeed(&mut (self.0).$n))).is_none() {
1320
0
                                    return Err(Error::invalid_length($n, &self));
1321
0
                                }
1322
0
                            )+
1323
0
1324
0
                            Ok(())
1325
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::<_>
1326
0
                    }
1327
0
1328
0
                    deserializer.deserialize_tuple($len, TupleInPlaceVisitor(place))
1329
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::<_>
1330
            }
1331
        )+
1332
    }
1333
}
1334
1335
tuple_impls! {
1336
    1  => (0 T0)
1337
    2  => (0 T0 1 T1)
1338
    3  => (0 T0 1 T1 2 T2)
1339
    4  => (0 T0 1 T1 2 T2 3 T3)
1340
    5  => (0 T0 1 T1 2 T2 3 T3 4 T4)
1341
    6  => (0 T0 1 T1 2 T2 3 T3 4 T4 5 T5)
1342
    7  => (0 T0 1 T1 2 T2 3 T3 4 T4 5 T5 6 T6)
1343
    8  => (0 T0 1 T1 2 T2 3 T3 4 T4 5 T5 6 T6 7 T7)
1344
    9  => (0 T0 1 T1 2 T2 3 T3 4 T4 5 T5 6 T6 7 T7 8 T8)
1345
    10 => (0 T0 1 T1 2 T2 3 T3 4 T4 5 T5 6 T6 7 T7 8 T8 9 T9)
1346
    11 => (0 T0 1 T1 2 T2 3 T3 4 T4 5 T5 6 T6 7 T7 8 T8 9 T9 10 T10)
1347
    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)
1348
    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)
1349
    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)
1350
    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)
1351
    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)
1352
}
1353
1354
////////////////////////////////////////////////////////////////////////////////
1355
1356
#[cfg(any(feature = "std", feature = "alloc"))]
1357
macro_rules! map_impl {
1358
    (
1359
        $ty:ident <K $(: $kbound1:ident $(+ $kbound2:ident)*)*, V $(, $typaram:ident : $bound1:ident $(+ $bound2:ident)*)*>,
1360
        $access:ident,
1361
        $with_capacity:expr
1362
    ) => {
1363
        impl<'de, K, V $(, $typaram)*> Deserialize<'de> for $ty<K, V $(, $typaram)*>
1364
        where
1365
            K: Deserialize<'de> $(+ $kbound1 $(+ $kbound2)*)*,
1366
            V: Deserialize<'de>,
1367
            $($typaram: $bound1 $(+ $bound2)*),*
1368
        {
1369
0
            fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
1370
0
            where
1371
0
                D: Deserializer<'de>,
1372
0
            {
1373
0
                struct MapVisitor<K, V $(, $typaram)*> {
1374
0
                    marker: PhantomData<$ty<K, V $(, $typaram)*>>,
1375
0
                }
1376
0
1377
0
                impl<'de, K, V $(, $typaram)*> Visitor<'de> for MapVisitor<K, V $(, $typaram)*>
1378
0
                where
1379
0
                    K: Deserialize<'de> $(+ $kbound1 $(+ $kbound2)*)*,
1380
0
                    V: Deserialize<'de>,
1381
0
                    $($typaram: $bound1 $(+ $bound2)*),*
1382
0
                {
1383
0
                    type Value = $ty<K, V $(, $typaram)*>;
1384
0
1385
0
                    fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
1386
0
                        formatter.write_str("a map")
1387
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
1388
0
1389
0
                    #[inline]
1390
0
                    fn visit_map<A>(self, mut $access: A) -> Result<Self::Value, A::Error>
1391
0
                    where
1392
0
                        A: MapAccess<'de>,
1393
0
                    {
1394
0
                        let mut values = $with_capacity;
1395
0
1396
0
                        while let Some((key, value)) = try!($access.next_entry()) {
1397
0
                            values.insert(key, value);
1398
0
                        }
1399
0
1400
0
                        Ok(values)
1401
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::<_>
1402
0
                }
1403
0
1404
0
                let visitor = MapVisitor { marker: PhantomData };
1405
0
                deserializer.deserialize_map(visitor)
1406
0
            }
Unexecuted instantiation: <std::collections::hash::map::HashMap<_, _, _> as serde::de::Deserialize>::deserialize::<_>
Unexecuted instantiation: <alloc::collections::btree::map::BTreeMap<_, _> as serde::de::Deserialize>::deserialize::<_>
1407
        }
1408
    }
1409
}
1410
1411
#[cfg(any(feature = "std", feature = "alloc"))]
1412
map_impl!(
1413
    BTreeMap<K: Ord, V>,
1414
    map,
1415
    BTreeMap::new());
1416
1417
#[cfg(feature = "std")]
1418
map_impl!(
1419
    HashMap<K: Eq + Hash, V, S: BuildHasher + Default>,
1420
    map,
1421
    HashMap::with_capacity_and_hasher(size_hint::cautious(map.size_hint()), S::default()));
1422
1423
////////////////////////////////////////////////////////////////////////////////
1424
1425
#[cfg(feature = "std")]
1426
macro_rules! parse_ip_impl {
1427
    ($expecting:tt $ty:ty; $size:tt) => {
1428
        impl<'de> Deserialize<'de> for $ty {
1429
0
            fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
1430
0
            where
1431
0
                D: Deserializer<'de>,
1432
0
            {
1433
0
                if deserializer.is_human_readable() {
1434
0
                    deserializer.deserialize_str(FromStrVisitor::new($expecting))
1435
                } else {
1436
0
                    <[u8; $size]>::deserialize(deserializer).map(<$ty>::from)
1437
                }
1438
0
            }
Unexecuted instantiation: <core::net::ip_addr::Ipv6Addr as serde::de::Deserialize>::deserialize::<_>
Unexecuted instantiation: <core::net::ip_addr::Ipv4Addr as serde::de::Deserialize>::deserialize::<_>
1439
        }
1440
    };
1441
}
1442
1443
#[cfg(feature = "std")]
1444
macro_rules! variant_identifier {
1445
    (
1446
        $name_kind:ident ($($variant:ident; $bytes:expr; $index:expr),*)
1447
        $expecting_message:expr,
1448
        $variants_name:ident
1449
    ) => {
1450
        enum $name_kind {
1451
            $($variant),*
1452
        }
1453
1454
        static $variants_name: &'static [&'static str] = &[$(stringify!($variant)),*];
1455
1456
        impl<'de> Deserialize<'de> for $name_kind {
1457
0
            fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
1458
0
            where
1459
0
                D: Deserializer<'de>,
1460
0
            {
1461
0
                struct KindVisitor;
1462
0
1463
0
                impl<'de> Visitor<'de> for KindVisitor {
1464
0
                    type Value = $name_kind;
1465
0
1466
0
                    fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
1467
0
                        formatter.write_str($expecting_message)
1468
0
                    }
1469
0
1470
0
                    fn visit_u64<E>(self, value: u64) -> Result<Self::Value, E>
1471
0
                    where
1472
0
                        E: Error,
1473
0
                    {
1474
0
                        match value {
1475
0
                            $(
1476
0
                                $index => Ok($name_kind :: $variant),
1477
0
                            )*
1478
0
                            _ => Err(Error::invalid_value(Unexpected::Unsigned(value), &self),),
1479
0
                        }
1480
0
                    }
Unexecuted instantiation: <<serde::de::impls::OsStringKind as serde::de::Deserialize>::deserialize::KindVisitor as serde::de::Visitor>::visit_u64::<_>
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::<_>
1481
0
1482
0
                    fn visit_str<E>(self, value: &str) -> Result<Self::Value, E>
1483
0
                    where
1484
0
                        E: Error,
1485
0
                    {
1486
0
                        match value {
1487
0
                            $(
1488
0
                                stringify!($variant) => Ok($name_kind :: $variant),
1489
0
                            )*
1490
0
                            _ => Err(Error::unknown_variant(value, $variants_name)),
1491
0
                        }
1492
0
                    }
Unexecuted instantiation: <<serde::de::impls::OsStringKind 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: <<<core::net::ip_addr::IpAddr as serde::de::Deserialize>::deserialize::IpAddrKind as serde::de::Deserialize>::deserialize::KindVisitor as serde::de::Visitor>::visit_str::<_>
1493
0
1494
0
                    fn visit_bytes<E>(self, value: &[u8]) -> Result<Self::Value, E>
1495
0
                    where
1496
0
                        E: Error,
1497
0
                    {
1498
0
                        match value {
1499
0
                            $(
1500
0
                                $bytes => Ok($name_kind :: $variant),
1501
0
                            )*
1502
0
                            _ => {
1503
0
                                match str::from_utf8(value) {
1504
0
                                    Ok(value) => Err(Error::unknown_variant(value, $variants_name)),
1505
0
                                    Err(_) => Err(Error::invalid_value(Unexpected::Bytes(value), &self)),
1506
0
                                }
1507
0
                            }
1508
0
                        }
1509
0
                    }
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: <<<core::net::ip_addr::IpAddr as serde::de::Deserialize>::deserialize::IpAddrKind as serde::de::Deserialize>::deserialize::KindVisitor as serde::de::Visitor>::visit_bytes::<_>
1510
0
                }
1511
0
1512
0
                deserializer.deserialize_identifier(KindVisitor)
1513
0
            }
Unexecuted instantiation: <<core::net::socket_addr::SocketAddr as serde::de::Deserialize>::deserialize::SocketAddrKind as serde::de::Deserialize>::deserialize::<_>
Unexecuted instantiation: <<core::net::ip_addr::IpAddr as serde::de::Deserialize>::deserialize::IpAddrKind as serde::de::Deserialize>::deserialize::<_>
Unexecuted instantiation: <serde::de::impls::OsStringKind as serde::de::Deserialize>::deserialize::<_>
1514
        }
1515
    }
1516
}
1517
1518
#[cfg(feature = "std")]
1519
macro_rules! deserialize_enum {
1520
    (
1521
        $name:ident $name_kind:ident ($($variant:ident; $bytes:expr; $index:expr),*)
1522
        $expecting_message:expr,
1523
        $deserializer:expr
1524
    ) => {
1525
        variant_identifier! {
1526
            $name_kind ($($variant; $bytes; $index),*)
1527
            $expecting_message,
1528
            VARIANTS
1529
        }
1530
1531
        struct EnumVisitor;
1532
        impl<'de> Visitor<'de> for EnumVisitor {
1533
            type Value = $name;
1534
1535
            fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
1536
                formatter.write_str(concat!("a ", stringify!($name)))
1537
            }
1538
1539
1540
0
            fn visit_enum<A>(self, data: A) -> Result<Self::Value, A::Error>
1541
0
            where
1542
0
                A: EnumAccess<'de>,
1543
0
            {
1544
0
                match try!(data.variant()) {
1545
                    $(
1546
0
                        ($name_kind :: $variant, v) => v.newtype_variant().map($name :: $variant),
1547
                    )*
1548
                }
1549
0
            }
Unexecuted instantiation: <<core::net::socket_addr::SocketAddr as serde::de::Deserialize>::deserialize::EnumVisitor as serde::de::Visitor>::visit_enum::<_>
Unexecuted instantiation: <<core::net::ip_addr::IpAddr as serde::de::Deserialize>::deserialize::EnumVisitor as serde::de::Visitor>::visit_enum::<_>
1550
        }
1551
        $deserializer.deserialize_enum(stringify!($name), VARIANTS, EnumVisitor)
1552
    }
1553
}
1554
1555
#[cfg(feature = "std")]
1556
impl<'de> Deserialize<'de> for net::IpAddr {
1557
0
    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
1558
0
    where
1559
0
        D: Deserializer<'de>,
1560
0
    {
1561
0
        if deserializer.is_human_readable() {
1562
0
            deserializer.deserialize_str(FromStrVisitor::new("IP address"))
1563
        } else {
1564
            use lib::net::IpAddr;
1565
0
            deserialize_enum! {
1566
0
                IpAddr IpAddrKind (V4; b"V4"; 0, V6; b"V6"; 1)
1567
0
                "`V4` or `V6`",
1568
0
                deserializer
1569
0
            }
1570
        }
1571
0
    }
1572
}
1573
1574
#[cfg(feature = "std")]
1575
parse_ip_impl!("IPv4 address" net::Ipv4Addr; 4);
1576
1577
#[cfg(feature = "std")]
1578
parse_ip_impl!("IPv6 address" net::Ipv6Addr; 16);
1579
1580
#[cfg(feature = "std")]
1581
macro_rules! parse_socket_impl {
1582
    ($expecting:tt $ty:ty, $new:expr) => {
1583
        impl<'de> Deserialize<'de> for $ty {
1584
0
            fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
1585
0
            where
1586
0
                D: Deserializer<'de>,
1587
0
            {
1588
0
                if deserializer.is_human_readable() {
1589
0
                    deserializer.deserialize_str(FromStrVisitor::new($expecting))
1590
                } else {
1591
0
                    <(_, u16)>::deserialize(deserializer).map(|(ip, port)| $new(ip, port))
1592
                }
1593
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::<_>
1594
        }
1595
    };
1596
}
1597
1598
#[cfg(feature = "std")]
1599
impl<'de> Deserialize<'de> for net::SocketAddr {
1600
0
    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
1601
0
    where
1602
0
        D: Deserializer<'de>,
1603
0
    {
1604
0
        if deserializer.is_human_readable() {
1605
0
            deserializer.deserialize_str(FromStrVisitor::new("socket address"))
1606
        } else {
1607
            use lib::net::SocketAddr;
1608
0
            deserialize_enum! {
1609
0
                SocketAddr SocketAddrKind (V4; b"V4"; 0, V6; b"V6"; 1)
1610
0
                "`V4` or `V6`",
1611
0
                deserializer
1612
0
            }
1613
        }
1614
0
    }
1615
}
1616
1617
#[cfg(feature = "std")]
1618
0
parse_socket_impl!("IPv4 socket address" net::SocketAddrV4, net::SocketAddrV4::new);
1619
1620
#[cfg(feature = "std")]
1621
0
parse_socket_impl!("IPv6 socket address" net::SocketAddrV6, |ip, port| net::SocketAddrV6::new(
1622
0
    ip, port, 0, 0
1623
0
));
1624
1625
////////////////////////////////////////////////////////////////////////////////
1626
1627
#[cfg(feature = "std")]
1628
struct PathVisitor;
1629
1630
#[cfg(feature = "std")]
1631
impl<'a> Visitor<'a> for PathVisitor {
1632
    type Value = &'a Path;
1633
1634
    fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
1635
        formatter.write_str("a borrowed path")
1636
    }
1637
1638
0
    fn visit_borrowed_str<E>(self, v: &'a str) -> Result<Self::Value, E>
1639
0
    where
1640
0
        E: Error,
1641
0
    {
1642
0
        Ok(v.as_ref())
1643
0
    }
1644
1645
0
    fn visit_borrowed_bytes<E>(self, v: &'a [u8]) -> Result<Self::Value, E>
1646
0
    where
1647
0
        E: Error,
1648
0
    {
1649
0
        str::from_utf8(v)
1650
0
            .map(AsRef::as_ref)
1651
0
            .map_err(|_| Error::invalid_value(Unexpected::Bytes(v), &self))
1652
0
    }
1653
}
1654
1655
#[cfg(feature = "std")]
1656
impl<'de: 'a, 'a> Deserialize<'de> for &'a Path {
1657
0
    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
1658
0
    where
1659
0
        D: Deserializer<'de>,
1660
0
    {
1661
0
        deserializer.deserialize_str(PathVisitor)
1662
0
    }
1663
}
1664
1665
#[cfg(feature = "std")]
1666
struct PathBufVisitor;
1667
1668
#[cfg(feature = "std")]
1669
impl<'de> Visitor<'de> for PathBufVisitor {
1670
    type Value = PathBuf;
1671
1672
    fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
1673
        formatter.write_str("path string")
1674
    }
1675
1676
0
    fn visit_str<E>(self, v: &str) -> Result<Self::Value, E>
1677
0
    where
1678
0
        E: Error,
1679
0
    {
1680
0
        Ok(From::from(v))
1681
0
    }
1682
1683
0
    fn visit_string<E>(self, v: String) -> Result<Self::Value, E>
1684
0
    where
1685
0
        E: Error,
1686
0
    {
1687
0
        Ok(From::from(v))
1688
0
    }
1689
1690
0
    fn visit_bytes<E>(self, v: &[u8]) -> Result<Self::Value, E>
1691
0
    where
1692
0
        E: Error,
1693
0
    {
1694
0
        str::from_utf8(v)
1695
0
            .map(From::from)
1696
0
            .map_err(|_| Error::invalid_value(Unexpected::Bytes(v), &self))
1697
0
    }
1698
1699
0
    fn visit_byte_buf<E>(self, v: Vec<u8>) -> Result<Self::Value, E>
1700
0
    where
1701
0
        E: Error,
1702
0
    {
1703
0
        String::from_utf8(v)
1704
0
            .map(From::from)
1705
0
            .map_err(|e| Error::invalid_value(Unexpected::Bytes(&e.into_bytes()), &self))
1706
0
    }
1707
}
1708
1709
#[cfg(feature = "std")]
1710
impl<'de> Deserialize<'de> for PathBuf {
1711
0
    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
1712
0
    where
1713
0
        D: Deserializer<'de>,
1714
0
    {
1715
0
        deserializer.deserialize_string(PathBufVisitor)
1716
0
    }
1717
}
1718
1719
#[cfg(all(feature = "std", not(no_de_boxed_path)))]
1720
forwarded_impl!((), Box<Path>, PathBuf::into_boxed_path);
1721
1722
////////////////////////////////////////////////////////////////////////////////
1723
1724
// If this were outside of the serde crate, it would just use:
1725
//
1726
//    #[derive(Deserialize)]
1727
//    #[serde(variant_identifier)]
1728
#[cfg(all(feature = "std", any(unix, windows)))]
1729
variant_identifier! {
1730
    OsStringKind (Unix; b"Unix"; 0, Windows; b"Windows"; 1)
1731
    "`Unix` or `Windows`",
1732
    OSSTR_VARIANTS
1733
}
1734
1735
#[cfg(all(feature = "std", any(unix, windows)))]
1736
struct OsStringVisitor;
1737
1738
#[cfg(all(feature = "std", any(unix, windows)))]
1739
impl<'de> Visitor<'de> for OsStringVisitor {
1740
    type Value = OsString;
1741
1742
    fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
1743
        formatter.write_str("os string")
1744
    }
1745
1746
    #[cfg(unix)]
1747
0
    fn visit_enum<A>(self, data: A) -> Result<Self::Value, A::Error>
1748
0
    where
1749
0
        A: EnumAccess<'de>,
1750
0
    {
1751
        use std::os::unix::ffi::OsStringExt;
1752
1753
0
        match try!(data.variant()) {
1754
0
            (OsStringKind::Unix, v) => v.newtype_variant().map(OsString::from_vec),
1755
0
            (OsStringKind::Windows, _) => Err(Error::custom(
1756
0
                "cannot deserialize Windows OS string on Unix",
1757
0
            )),
1758
        }
1759
0
    }
1760
1761
    #[cfg(windows)]
1762
    fn visit_enum<A>(self, data: A) -> Result<Self::Value, A::Error>
1763
    where
1764
        A: EnumAccess<'de>,
1765
    {
1766
        use std::os::windows::ffi::OsStringExt;
1767
1768
        match try!(data.variant()) {
1769
            (OsStringKind::Windows, v) => v
1770
                .newtype_variant::<Vec<u16>>()
1771
                .map(|vec| OsString::from_wide(&vec)),
1772
            (OsStringKind::Unix, _) => Err(Error::custom(
1773
                "cannot deserialize Unix OS string on Windows",
1774
            )),
1775
        }
1776
    }
1777
}
1778
1779
#[cfg(all(feature = "std", any(unix, windows)))]
1780
impl<'de> Deserialize<'de> for OsString {
1781
0
    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
1782
0
    where
1783
0
        D: Deserializer<'de>,
1784
0
    {
1785
0
        deserializer.deserialize_enum("OsString", OSSTR_VARIANTS, OsStringVisitor)
1786
0
    }
1787
}
1788
1789
////////////////////////////////////////////////////////////////////////////////
1790
1791
#[cfg(any(feature = "std", feature = "alloc"))]
1792
forwarded_impl!((T), Box<T>, Box::new);
1793
1794
#[cfg(any(feature = "std", feature = "alloc"))]
1795
forwarded_impl!((T), Box<[T]>, Vec::into_boxed_slice);
1796
1797
#[cfg(any(feature = "std", feature = "alloc"))]
1798
forwarded_impl!((), Box<str>, String::into_boxed_str);
1799
1800
#[cfg(all(no_de_rc_dst, feature = "rc", any(feature = "std", feature = "alloc")))]
1801
forwarded_impl! {
1802
    /// This impl requires the [`"rc"`] Cargo feature of Serde.
1803
    ///
1804
    /// Deserializing a data structure containing `Arc` will not attempt to
1805
    /// deduplicate `Arc` references to the same data. Every deserialized `Arc`
1806
    /// will end up with a strong count of 1.
1807
    ///
1808
    /// [`"rc"`]: https://serde.rs/feature-flags.html#-features-rc
1809
    (T), Arc<T>, Arc::new
1810
}
1811
1812
#[cfg(all(no_de_rc_dst, feature = "rc", any(feature = "std", feature = "alloc")))]
1813
forwarded_impl! {
1814
    /// This impl requires the [`"rc"`] Cargo feature of Serde.
1815
    ///
1816
    /// Deserializing a data structure containing `Rc` will not attempt to
1817
    /// deduplicate `Rc` references to the same data. Every deserialized `Rc`
1818
    /// will end up with a strong count of 1.
1819
    ///
1820
    /// [`"rc"`]: https://serde.rs/feature-flags.html#-features-rc
1821
    (T), Rc<T>, Rc::new
1822
}
1823
1824
#[cfg(any(feature = "std", feature = "alloc"))]
1825
impl<'de, 'a, T: ?Sized> Deserialize<'de> for Cow<'a, T>
1826
where
1827
    T: ToOwned,
1828
    T::Owned: Deserialize<'de>,
1829
{
1830
    #[inline]
1831
0
    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
1832
0
    where
1833
0
        D: Deserializer<'de>,
1834
0
    {
1835
0
        T::Owned::deserialize(deserializer).map(Cow::Owned)
1836
0
    }
1837
}
1838
1839
////////////////////////////////////////////////////////////////////////////////
1840
1841
/// This impl requires the [`"rc"`] Cargo feature of Serde. The resulting
1842
/// `Weak<T>` has a reference count of 0 and cannot be upgraded.
1843
///
1844
/// [`"rc"`]: https://serde.rs/feature-flags.html#-features-rc
1845
#[cfg(all(feature = "rc", any(feature = "std", feature = "alloc")))]
1846
impl<'de, T: ?Sized> Deserialize<'de> for RcWeak<T>
1847
where
1848
    T: Deserialize<'de>,
1849
{
1850
    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
1851
    where
1852
        D: Deserializer<'de>,
1853
    {
1854
        try!(Option::<T>::deserialize(deserializer));
1855
        Ok(RcWeak::new())
1856
    }
1857
}
1858
1859
/// This impl requires the [`"rc"`] Cargo feature of Serde. The resulting
1860
/// `Weak<T>` has a reference count of 0 and cannot be upgraded.
1861
///
1862
/// [`"rc"`]: https://serde.rs/feature-flags.html#-features-rc
1863
#[cfg(all(feature = "rc", any(feature = "std", feature = "alloc")))]
1864
impl<'de, T: ?Sized> Deserialize<'de> for ArcWeak<T>
1865
where
1866
    T: Deserialize<'de>,
1867
{
1868
    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
1869
    where
1870
        D: Deserializer<'de>,
1871
    {
1872
        try!(Option::<T>::deserialize(deserializer));
1873
        Ok(ArcWeak::new())
1874
    }
1875
}
1876
1877
////////////////////////////////////////////////////////////////////////////////
1878
1879
#[cfg(all(
1880
    not(no_de_rc_dst),
1881
    feature = "rc",
1882
    any(feature = "std", feature = "alloc")
1883
))]
1884
macro_rules! box_forwarded_impl {
1885
    (
1886
        $(#[doc = $doc:tt])*
1887
        $t:ident
1888
    ) => {
1889
        $(#[doc = $doc])*
1890
        impl<'de, T: ?Sized> Deserialize<'de> for $t<T>
1891
        where
1892
            Box<T>: Deserialize<'de>,
1893
        {
1894
            fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
1895
            where
1896
                D: Deserializer<'de>,
1897
            {
1898
                Box::deserialize(deserializer).map(Into::into)
1899
            }
1900
        }
1901
    };
1902
}
1903
1904
#[cfg(all(
1905
    not(no_de_rc_dst),
1906
    feature = "rc",
1907
    any(feature = "std", feature = "alloc")
1908
))]
1909
box_forwarded_impl! {
1910
    /// This impl requires the [`"rc"`] Cargo feature of Serde.
1911
    ///
1912
    /// Deserializing a data structure containing `Rc` will not attempt to
1913
    /// deduplicate `Rc` references to the same data. Every deserialized `Rc`
1914
    /// will end up with a strong count of 1.
1915
    ///
1916
    /// [`"rc"`]: https://serde.rs/feature-flags.html#-features-rc
1917
    Rc
1918
}
1919
1920
#[cfg(all(
1921
    not(no_de_rc_dst),
1922
    feature = "rc",
1923
    any(feature = "std", feature = "alloc")
1924
))]
1925
box_forwarded_impl! {
1926
    /// This impl requires the [`"rc"`] Cargo feature of Serde.
1927
    ///
1928
    /// Deserializing a data structure containing `Arc` will not attempt to
1929
    /// deduplicate `Arc` references to the same data. Every deserialized `Arc`
1930
    /// will end up with a strong count of 1.
1931
    ///
1932
    /// [`"rc"`]: https://serde.rs/feature-flags.html#-features-rc
1933
    Arc
1934
}
1935
1936
////////////////////////////////////////////////////////////////////////////////
1937
1938
impl<'de, T> Deserialize<'de> for Cell<T>
1939
where
1940
    T: Deserialize<'de> + Copy,
1941
{
1942
0
    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
1943
0
    where
1944
0
        D: Deserializer<'de>,
1945
0
    {
1946
0
        T::deserialize(deserializer).map(Cell::new)
1947
0
    }
1948
}
1949
1950
forwarded_impl!((T), RefCell<T>, RefCell::new);
1951
1952
#[cfg(feature = "std")]
1953
forwarded_impl!((T), Mutex<T>, Mutex::new);
1954
1955
#[cfg(feature = "std")]
1956
forwarded_impl!((T), RwLock<T>, RwLock::new);
1957
1958
////////////////////////////////////////////////////////////////////////////////
1959
1960
// This is a cleaned-up version of the impl generated by:
1961
//
1962
//     #[derive(Deserialize)]
1963
//     #[serde(deny_unknown_fields)]
1964
//     struct Duration {
1965
//         secs: u64,
1966
//         nanos: u32,
1967
//     }
1968
#[cfg(any(feature = "std", not(no_core_duration)))]
1969
impl<'de> Deserialize<'de> for Duration {
1970
0
    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
1971
0
    where
1972
0
        D: Deserializer<'de>,
1973
0
    {
1974
0
        // If this were outside of the serde crate, it would just use:
1975
0
        //
1976
0
        //    #[derive(Deserialize)]
1977
0
        //    #[serde(field_identifier, rename_all = "lowercase")]
1978
0
        enum Field {
1979
0
            Secs,
1980
0
            Nanos,
1981
0
        }
1982
0
1983
0
        impl<'de> Deserialize<'de> for Field {
1984
0
            fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
1985
0
            where
1986
0
                D: Deserializer<'de>,
1987
0
            {
1988
0
                struct FieldVisitor;
1989
0
1990
0
                impl<'de> Visitor<'de> for FieldVisitor {
1991
0
                    type Value = Field;
1992
0
1993
0
                    fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
1994
0
                        formatter.write_str("`secs` or `nanos`")
1995
0
                    }
1996
0
1997
0
                    fn visit_str<E>(self, value: &str) -> Result<Self::Value, E>
1998
0
                    where
1999
0
                        E: Error,
2000
0
                    {
2001
0
                        match value {
2002
0
                            "secs" => Ok(Field::Secs),
2003
0
                            "nanos" => Ok(Field::Nanos),
2004
0
                            _ => Err(Error::unknown_field(value, FIELDS)),
2005
0
                        }
2006
0
                    }
2007
0
2008
0
                    fn visit_bytes<E>(self, value: &[u8]) -> Result<Self::Value, E>
2009
0
                    where
2010
0
                        E: Error,
2011
0
                    {
2012
0
                        match value {
2013
0
                            b"secs" => Ok(Field::Secs),
2014
0
                            b"nanos" => Ok(Field::Nanos),
2015
0
                            _ => {
2016
0
                                let value = ::__private::from_utf8_lossy(value);
2017
0
                                Err(Error::unknown_field(&*value, FIELDS))
2018
0
                            }
2019
0
                        }
2020
0
                    }
2021
0
                }
2022
0
2023
0
                deserializer.deserialize_identifier(FieldVisitor)
2024
0
            }
2025
0
        }
2026
0
2027
0
        fn check_overflow<E>(secs: u64, nanos: u32) -> Result<(), E>
2028
0
        where
2029
0
            E: Error,
2030
0
        {
2031
0
            static NANOS_PER_SEC: u32 = 1_000_000_000;
2032
0
            match secs.checked_add((nanos / NANOS_PER_SEC) as u64) {
2033
0
                Some(_) => Ok(()),
2034
0
                None => Err(E::custom("overflow deserializing Duration")),
2035
0
            }
2036
0
        }
2037
0
2038
0
        struct DurationVisitor;
2039
0
2040
0
        impl<'de> Visitor<'de> for DurationVisitor {
2041
0
            type Value = Duration;
2042
0
2043
0
            fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
2044
0
                formatter.write_str("struct Duration")
2045
0
            }
2046
0
2047
0
            fn visit_seq<A>(self, mut seq: A) -> Result<Self::Value, A::Error>
2048
0
            where
2049
0
                A: SeqAccess<'de>,
2050
0
            {
2051
0
                let secs: u64 = match try!(seq.next_element()) {
2052
0
                    Some(value) => value,
2053
0
                    None => {
2054
0
                        return Err(Error::invalid_length(0, &self));
2055
0
                    }
2056
0
                };
2057
0
                let nanos: u32 = match try!(seq.next_element()) {
2058
0
                    Some(value) => value,
2059
0
                    None => {
2060
0
                        return Err(Error::invalid_length(1, &self));
2061
0
                    }
2062
0
                };
2063
0
                try!(check_overflow(secs, nanos));
2064
0
                Ok(Duration::new(secs, nanos))
2065
0
            }
2066
0
2067
0
            fn visit_map<A>(self, mut map: A) -> Result<Self::Value, A::Error>
2068
0
            where
2069
0
                A: MapAccess<'de>,
2070
0
            {
2071
0
                let mut secs: Option<u64> = None;
2072
0
                let mut nanos: Option<u32> = None;
2073
0
                while let Some(key) = try!(map.next_key()) {
2074
0
                    match key {
2075
0
                        Field::Secs => {
2076
0
                            if secs.is_some() {
2077
0
                                return Err(<A::Error as Error>::duplicate_field("secs"));
2078
0
                            }
2079
0
                            secs = Some(try!(map.next_value()));
2080
0
                        }
2081
0
                        Field::Nanos => {
2082
0
                            if nanos.is_some() {
2083
0
                                return Err(<A::Error as Error>::duplicate_field("nanos"));
2084
0
                            }
2085
0
                            nanos = Some(try!(map.next_value()));
2086
0
                        }
2087
0
                    }
2088
0
                }
2089
0
                let secs = match secs {
2090
0
                    Some(secs) => secs,
2091
0
                    None => return Err(<A::Error as Error>::missing_field("secs")),
2092
0
                };
2093
0
                let nanos = match nanos {
2094
0
                    Some(nanos) => nanos,
2095
0
                    None => return Err(<A::Error as Error>::missing_field("nanos")),
2096
0
                };
2097
0
                try!(check_overflow(secs, nanos));
2098
0
                Ok(Duration::new(secs, nanos))
2099
0
            }
2100
0
        }
2101
0
2102
0
        const FIELDS: &'static [&'static str] = &["secs", "nanos"];
2103
0
        deserializer.deserialize_struct("Duration", FIELDS, DurationVisitor)
2104
0
    }
2105
}
2106
2107
////////////////////////////////////////////////////////////////////////////////
2108
2109
#[cfg(feature = "std")]
2110
impl<'de> Deserialize<'de> for SystemTime {
2111
0
    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
2112
0
    where
2113
0
        D: Deserializer<'de>,
2114
0
    {
2115
        // Reuse duration
2116
        enum Field {
2117
            Secs,
2118
            Nanos,
2119
        }
2120
2121
        impl<'de> Deserialize<'de> for Field {
2122
0
            fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
2123
0
            where
2124
0
                D: Deserializer<'de>,
2125
0
            {
2126
0
                struct FieldVisitor;
2127
0
2128
0
                impl<'de> Visitor<'de> for FieldVisitor {
2129
0
                    type Value = Field;
2130
0
2131
0
                    fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
2132
0
                        formatter.write_str("`secs_since_epoch` or `nanos_since_epoch`")
2133
0
                    }
2134
0
2135
0
                    fn visit_str<E>(self, value: &str) -> Result<Self::Value, E>
2136
0
                    where
2137
0
                        E: Error,
2138
0
                    {
2139
0
                        match value {
2140
0
                            "secs_since_epoch" => Ok(Field::Secs),
2141
0
                            "nanos_since_epoch" => Ok(Field::Nanos),
2142
0
                            _ => Err(Error::unknown_field(value, FIELDS)),
2143
0
                        }
2144
0
                    }
2145
0
2146
0
                    fn visit_bytes<E>(self, value: &[u8]) -> Result<Self::Value, E>
2147
0
                    where
2148
0
                        E: Error,
2149
0
                    {
2150
0
                        match value {
2151
0
                            b"secs_since_epoch" => Ok(Field::Secs),
2152
0
                            b"nanos_since_epoch" => Ok(Field::Nanos),
2153
0
                            _ => {
2154
0
                                let value = String::from_utf8_lossy(value);
2155
0
                                Err(Error::unknown_field(&value, FIELDS))
2156
0
                            }
2157
0
                        }
2158
0
                    }
2159
0
                }
2160
0
2161
0
                deserializer.deserialize_identifier(FieldVisitor)
2162
0
            }
2163
        }
2164
2165
0
        fn check_overflow<E>(secs: u64, nanos: u32) -> Result<(), E>
2166
0
        where
2167
0
            E: Error,
2168
0
        {
2169
0
            static NANOS_PER_SEC: u32 = 1_000_000_000;
2170
0
            match secs.checked_add((nanos / NANOS_PER_SEC) as u64) {
2171
0
                Some(_) => Ok(()),
2172
0
                None => Err(E::custom("overflow deserializing SystemTime epoch offset")),
2173
            }
2174
0
        }
2175
2176
        struct DurationVisitor;
2177
2178
        impl<'de> Visitor<'de> for DurationVisitor {
2179
            type Value = Duration;
2180
2181
            fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
2182
                formatter.write_str("struct SystemTime")
2183
            }
2184
2185
0
            fn visit_seq<A>(self, mut seq: A) -> Result<Self::Value, A::Error>
2186
0
            where
2187
0
                A: SeqAccess<'de>,
2188
0
            {
2189
0
                let secs: u64 = match try!(seq.next_element()) {
2190
0
                    Some(value) => value,
2191
                    None => {
2192
0
                        return Err(Error::invalid_length(0, &self));
2193
                    }
2194
                };
2195
0
                let nanos: u32 = match try!(seq.next_element()) {
2196
0
                    Some(value) => value,
2197
                    None => {
2198
0
                        return Err(Error::invalid_length(1, &self));
2199
                    }
2200
                };
2201
0
                try!(check_overflow(secs, nanos));
2202
0
                Ok(Duration::new(secs, nanos))
2203
0
            }
2204
2205
0
            fn visit_map<A>(self, mut map: A) -> Result<Self::Value, A::Error>
2206
0
            where
2207
0
                A: MapAccess<'de>,
2208
0
            {
2209
0
                let mut secs: Option<u64> = None;
2210
0
                let mut nanos: Option<u32> = None;
2211
0
                while let Some(key) = try!(map.next_key()) {
2212
0
                    match key {
2213
                        Field::Secs => {
2214
0
                            if secs.is_some() {
2215
0
                                return Err(<A::Error as Error>::duplicate_field(
2216
0
                                    "secs_since_epoch",
2217
0
                                ));
2218
0
                            }
2219
0
                            secs = Some(try!(map.next_value()));
2220
                        }
2221
                        Field::Nanos => {
2222
0
                            if nanos.is_some() {
2223
0
                                return Err(<A::Error as Error>::duplicate_field(
2224
0
                                    "nanos_since_epoch",
2225
0
                                ));
2226
0
                            }
2227
0
                            nanos = Some(try!(map.next_value()));
2228
                        }
2229
                    }
2230
                }
2231
0
                let secs = match secs {
2232
0
                    Some(secs) => secs,
2233
0
                    None => return Err(<A::Error as Error>::missing_field("secs_since_epoch")),
2234
                };
2235
0
                let nanos = match nanos {
2236
0
                    Some(nanos) => nanos,
2237
0
                    None => return Err(<A::Error as Error>::missing_field("nanos_since_epoch")),
2238
                };
2239
0
                try!(check_overflow(secs, nanos));
2240
0
                Ok(Duration::new(secs, nanos))
2241
0
            }
2242
        }
2243
2244
        const FIELDS: &'static [&'static str] = &["secs_since_epoch", "nanos_since_epoch"];
2245
0
        let duration = try!(deserializer.deserialize_struct("SystemTime", FIELDS, DurationVisitor));
2246
        #[cfg(not(no_systemtime_checked_add))]
2247
0
        let ret = UNIX_EPOCH
2248
0
            .checked_add(duration)
2249
0
            .ok_or_else(|| D::Error::custom("overflow deserializing SystemTime"));
2250
0
        #[cfg(no_systemtime_checked_add)]
2251
0
        let ret = Ok(UNIX_EPOCH + duration);
2252
0
        ret
2253
0
    }
2254
}
2255
2256
////////////////////////////////////////////////////////////////////////////////
2257
2258
// Similar to:
2259
//
2260
//     #[derive(Deserialize)]
2261
//     #[serde(deny_unknown_fields)]
2262
//     struct Range {
2263
//         start: u64,
2264
//         end: u32,
2265
//     }
2266
impl<'de, Idx> Deserialize<'de> for Range<Idx>
2267
where
2268
    Idx: Deserialize<'de>,
2269
{
2270
0
    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
2271
0
    where
2272
0
        D: Deserializer<'de>,
2273
0
    {
2274
0
        let (start, end) = try!(deserializer.deserialize_struct(
2275
0
            "Range",
2276
0
            range::FIELDS,
2277
0
            range::RangeVisitor {
2278
0
                expecting: "struct Range",
2279
0
                phantom: PhantomData,
2280
0
            },
2281
0
        ));
2282
0
        Ok(start..end)
2283
0
    }
2284
}
2285
2286
#[cfg(not(no_range_inclusive))]
2287
impl<'de, Idx> Deserialize<'de> for RangeInclusive<Idx>
2288
where
2289
    Idx: Deserialize<'de>,
2290
{
2291
0
    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
2292
0
    where
2293
0
        D: Deserializer<'de>,
2294
0
    {
2295
0
        let (start, end) = try!(deserializer.deserialize_struct(
2296
0
            "RangeInclusive",
2297
0
            range::FIELDS,
2298
0
            range::RangeVisitor {
2299
0
                expecting: "struct RangeInclusive",
2300
0
                phantom: PhantomData,
2301
0
            },
2302
0
        ));
2303
0
        Ok(RangeInclusive::new(start, end))
2304
0
    }
2305
}
2306
2307
mod range {
2308
    use lib::*;
2309
2310
    use de::{Deserialize, Deserializer, Error, MapAccess, SeqAccess, Visitor};
2311
2312
    pub const FIELDS: &'static [&'static str] = &["start", "end"];
2313
2314
    // If this were outside of the serde crate, it would just use:
2315
    //
2316
    //    #[derive(Deserialize)]
2317
    //    #[serde(field_identifier, rename_all = "lowercase")]
2318
    enum Field {
2319
        Start,
2320
        End,
2321
    }
2322
2323
    impl<'de> Deserialize<'de> for Field {
2324
0
        fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
2325
0
        where
2326
0
            D: Deserializer<'de>,
2327
0
        {
2328
0
            struct FieldVisitor;
2329
0
2330
0
            impl<'de> Visitor<'de> for FieldVisitor {
2331
0
                type Value = Field;
2332
0
2333
0
                fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
2334
0
                    formatter.write_str("`start` or `end`")
2335
0
                }
2336
0
2337
0
                fn visit_str<E>(self, value: &str) -> Result<Self::Value, E>
2338
0
                where
2339
0
                    E: Error,
2340
0
                {
2341
0
                    match value {
2342
0
                        "start" => Ok(Field::Start),
2343
0
                        "end" => Ok(Field::End),
2344
0
                        _ => Err(Error::unknown_field(value, FIELDS)),
2345
0
                    }
2346
0
                }
2347
0
2348
0
                fn visit_bytes<E>(self, value: &[u8]) -> Result<Self::Value, E>
2349
0
                where
2350
0
                    E: Error,
2351
0
                {
2352
0
                    match value {
2353
0
                        b"start" => Ok(Field::Start),
2354
0
                        b"end" => Ok(Field::End),
2355
0
                        _ => {
2356
0
                            let value = ::__private::from_utf8_lossy(value);
2357
0
                            Err(Error::unknown_field(&*value, FIELDS))
2358
0
                        }
2359
0
                    }
2360
0
                }
2361
0
            }
2362
0
2363
0
            deserializer.deserialize_identifier(FieldVisitor)
2364
0
        }
2365
    }
2366
2367
    pub struct RangeVisitor<Idx> {
2368
        pub expecting: &'static str,
2369
        pub phantom: PhantomData<Idx>,
2370
    }
2371
2372
    impl<'de, Idx> Visitor<'de> for RangeVisitor<Idx>
2373
    where
2374
        Idx: Deserialize<'de>,
2375
    {
2376
        type Value = (Idx, Idx);
2377
2378
0
        fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
2379
0
            formatter.write_str(self.expecting)
2380
0
        }
2381
2382
0
        fn visit_seq<A>(self, mut seq: A) -> Result<Self::Value, A::Error>
2383
0
        where
2384
0
            A: SeqAccess<'de>,
2385
0
        {
2386
0
            let start: Idx = match try!(seq.next_element()) {
2387
0
                Some(value) => value,
2388
                None => {
2389
0
                    return Err(Error::invalid_length(0, &self));
2390
                }
2391
            };
2392
0
            let end: Idx = match try!(seq.next_element()) {
2393
0
                Some(value) => value,
2394
                None => {
2395
0
                    return Err(Error::invalid_length(1, &self));
2396
                }
2397
            };
2398
0
            Ok((start, end))
2399
0
        }
2400
2401
0
        fn visit_map<A>(self, mut map: A) -> Result<Self::Value, A::Error>
2402
0
        where
2403
0
            A: MapAccess<'de>,
2404
0
        {
2405
0
            let mut start: Option<Idx> = None;
2406
0
            let mut end: Option<Idx> = None;
2407
0
            while let Some(key) = try!(map.next_key()) {
2408
0
                match key {
2409
                    Field::Start => {
2410
0
                        if start.is_some() {
2411
0
                            return Err(<A::Error as Error>::duplicate_field("start"));
2412
0
                        }
2413
0
                        start = Some(try!(map.next_value()));
2414
                    }
2415
                    Field::End => {
2416
0
                        if end.is_some() {
2417
0
                            return Err(<A::Error as Error>::duplicate_field("end"));
2418
0
                        }
2419
0
                        end = Some(try!(map.next_value()));
2420
                    }
2421
                }
2422
            }
2423
0
            let start = match start {
2424
0
                Some(start) => start,
2425
0
                None => return Err(<A::Error as Error>::missing_field("start")),
2426
            };
2427
0
            let end = match end {
2428
0
                Some(end) => end,
2429
0
                None => return Err(<A::Error as Error>::missing_field("end")),
2430
            };
2431
0
            Ok((start, end))
2432
0
        }
2433
    }
2434
}
2435
2436
////////////////////////////////////////////////////////////////////////////////
2437
2438
#[cfg(any(not(no_ops_bound), all(feature = "std", not(no_collections_bound))))]
2439
impl<'de, T> Deserialize<'de> for Bound<T>
2440
where
2441
    T: Deserialize<'de>,
2442
{
2443
0
    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
2444
0
    where
2445
0
        D: Deserializer<'de>,
2446
0
    {
2447
0
        enum Field {
2448
0
            Unbounded,
2449
0
            Included,
2450
0
            Excluded,
2451
0
        }
2452
0
2453
0
        impl<'de> Deserialize<'de> for Field {
2454
0
            #[inline]
2455
0
            fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
2456
0
            where
2457
0
                D: Deserializer<'de>,
2458
0
            {
2459
0
                struct FieldVisitor;
2460
0
2461
0
                impl<'de> Visitor<'de> for FieldVisitor {
2462
0
                    type Value = Field;
2463
0
2464
0
                    fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
2465
0
                        formatter.write_str("`Unbounded`, `Included` or `Excluded`")
2466
0
                    }
2467
0
2468
0
                    fn visit_u64<E>(self, value: u64) -> Result<Self::Value, E>
2469
0
                    where
2470
0
                        E: Error,
2471
0
                    {
2472
0
                        match value {
2473
0
                            0 => Ok(Field::Unbounded),
2474
0
                            1 => Ok(Field::Included),
2475
0
                            2 => Ok(Field::Excluded),
2476
0
                            _ => Err(Error::invalid_value(Unexpected::Unsigned(value), &self)),
2477
0
                        }
2478
0
                    }
2479
0
2480
0
                    fn visit_str<E>(self, value: &str) -> Result<Self::Value, E>
2481
0
                    where
2482
0
                        E: Error,
2483
0
                    {
2484
0
                        match value {
2485
0
                            "Unbounded" => Ok(Field::Unbounded),
2486
0
                            "Included" => Ok(Field::Included),
2487
0
                            "Excluded" => Ok(Field::Excluded),
2488
0
                            _ => Err(Error::unknown_variant(value, VARIANTS)),
2489
0
                        }
2490
0
                    }
2491
0
2492
0
                    fn visit_bytes<E>(self, value: &[u8]) -> Result<Self::Value, E>
2493
0
                    where
2494
0
                        E: Error,
2495
0
                    {
2496
0
                        match value {
2497
0
                            b"Unbounded" => Ok(Field::Unbounded),
2498
0
                            b"Included" => Ok(Field::Included),
2499
0
                            b"Excluded" => Ok(Field::Excluded),
2500
0
                            _ => match str::from_utf8(value) {
2501
0
                                Ok(value) => Err(Error::unknown_variant(value, VARIANTS)),
2502
0
                                Err(_) => {
2503
0
                                    Err(Error::invalid_value(Unexpected::Bytes(value), &self))
2504
0
                                }
2505
0
                            },
2506
0
                        }
2507
0
                    }
2508
0
                }
2509
0
2510
0
                deserializer.deserialize_identifier(FieldVisitor)
2511
0
            }
2512
0
        }
2513
0
2514
0
        struct BoundVisitor<T>(PhantomData<Bound<T>>);
2515
0
2516
0
        impl<'de, T> Visitor<'de> for BoundVisitor<T>
2517
0
        where
2518
0
            T: Deserialize<'de>,
2519
0
        {
2520
0
            type Value = Bound<T>;
2521
0
2522
0
            fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
2523
0
                formatter.write_str("enum Bound")
2524
0
            }
2525
0
2526
0
            fn visit_enum<A>(self, data: A) -> Result<Self::Value, A::Error>
2527
0
            where
2528
0
                A: EnumAccess<'de>,
2529
0
            {
2530
0
                match try!(data.variant()) {
2531
0
                    (Field::Unbounded, v) => v.unit_variant().map(|()| Bound::Unbounded),
2532
0
                    (Field::Included, v) => v.newtype_variant().map(Bound::Included),
2533
0
                    (Field::Excluded, v) => v.newtype_variant().map(Bound::Excluded),
2534
0
                }
2535
0
            }
2536
0
        }
2537
0
2538
0
        const VARIANTS: &'static [&'static str] = &["Unbounded", "Included", "Excluded"];
2539
0
2540
0
        deserializer.deserialize_enum("Bound", VARIANTS, BoundVisitor(PhantomData))
2541
0
    }
2542
}
2543
2544
////////////////////////////////////////////////////////////////////////////////
2545
2546
impl<'de, T, E> Deserialize<'de> for Result<T, E>
2547
where
2548
    T: Deserialize<'de>,
2549
    E: Deserialize<'de>,
2550
{
2551
0
    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
2552
0
    where
2553
0
        D: Deserializer<'de>,
2554
0
    {
2555
0
        // If this were outside of the serde crate, it would just use:
2556
0
        //
2557
0
        //    #[derive(Deserialize)]
2558
0
        //    #[serde(variant_identifier)]
2559
0
        enum Field {
2560
0
            Ok,
2561
0
            Err,
2562
0
        }
2563
0
2564
0
        impl<'de> Deserialize<'de> for Field {
2565
0
            #[inline]
2566
0
            fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
2567
0
            where
2568
0
                D: Deserializer<'de>,
2569
0
            {
2570
0
                struct FieldVisitor;
2571
0
2572
0
                impl<'de> Visitor<'de> for FieldVisitor {
2573
0
                    type Value = Field;
2574
0
2575
0
                    fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
2576
0
                        formatter.write_str("`Ok` or `Err`")
2577
0
                    }
2578
0
2579
0
                    fn visit_u64<E>(self, value: u64) -> Result<Self::Value, E>
2580
0
                    where
2581
0
                        E: Error,
2582
0
                    {
2583
0
                        match value {
2584
0
                            0 => Ok(Field::Ok),
2585
0
                            1 => Ok(Field::Err),
2586
0
                            _ => Err(Error::invalid_value(Unexpected::Unsigned(value), &self)),
2587
0
                        }
2588
0
                    }
2589
0
2590
0
                    fn visit_str<E>(self, value: &str) -> Result<Self::Value, E>
2591
0
                    where
2592
0
                        E: Error,
2593
0
                    {
2594
0
                        match value {
2595
0
                            "Ok" => Ok(Field::Ok),
2596
0
                            "Err" => Ok(Field::Err),
2597
0
                            _ => Err(Error::unknown_variant(value, VARIANTS)),
2598
0
                        }
2599
0
                    }
2600
0
2601
0
                    fn visit_bytes<E>(self, value: &[u8]) -> Result<Self::Value, E>
2602
0
                    where
2603
0
                        E: Error,
2604
0
                    {
2605
0
                        match value {
2606
0
                            b"Ok" => Ok(Field::Ok),
2607
0
                            b"Err" => Ok(Field::Err),
2608
0
                            _ => match str::from_utf8(value) {
2609
0
                                Ok(value) => Err(Error::unknown_variant(value, VARIANTS)),
2610
0
                                Err(_) => {
2611
0
                                    Err(Error::invalid_value(Unexpected::Bytes(value), &self))
2612
0
                                }
2613
0
                            },
2614
0
                        }
2615
0
                    }
2616
0
                }
2617
0
2618
0
                deserializer.deserialize_identifier(FieldVisitor)
2619
0
            }
2620
0
        }
2621
0
2622
0
        struct ResultVisitor<T, E>(PhantomData<Result<T, E>>);
2623
0
2624
0
        impl<'de, T, E> Visitor<'de> for ResultVisitor<T, E>
2625
0
        where
2626
0
            T: Deserialize<'de>,
2627
0
            E: Deserialize<'de>,
2628
0
        {
2629
0
            type Value = Result<T, E>;
2630
0
2631
0
            fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
2632
0
                formatter.write_str("enum Result")
2633
0
            }
2634
0
2635
0
            fn visit_enum<A>(self, data: A) -> Result<Self::Value, A::Error>
2636
0
            where
2637
0
                A: EnumAccess<'de>,
2638
0
            {
2639
0
                match try!(data.variant()) {
2640
0
                    (Field::Ok, v) => v.newtype_variant().map(Ok),
2641
0
                    (Field::Err, v) => v.newtype_variant().map(Err),
2642
0
                }
2643
0
            }
2644
0
        }
2645
0
2646
0
        const VARIANTS: &'static [&'static str] = &["Ok", "Err"];
2647
0
2648
0
        deserializer.deserialize_enum("Result", VARIANTS, ResultVisitor(PhantomData))
2649
0
    }
2650
}
2651
2652
////////////////////////////////////////////////////////////////////////////////
2653
2654
impl<'de, T> Deserialize<'de> for Wrapping<T>
2655
where
2656
    T: Deserialize<'de>,
2657
{
2658
0
    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
2659
0
    where
2660
0
        D: Deserializer<'de>,
2661
0
    {
2662
0
        Deserialize::deserialize(deserializer).map(Wrapping)
2663
0
    }
2664
}
2665
2666
#[cfg(all(feature = "std", not(no_std_atomic)))]
2667
macro_rules! atomic_impl {
2668
    ($($ty:ident $size:expr)*) => {
2669
        $(
2670
            #[cfg(any(no_target_has_atomic, target_has_atomic = $size))]
2671
            impl<'de> Deserialize<'de> for $ty {
2672
0
                fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
2673
0
                where
2674
0
                    D: Deserializer<'de>,
2675
0
                {
2676
0
                    Deserialize::deserialize(deserializer).map(Self::new)
2677
0
                }
Unexecuted instantiation: <core::sync::atomic::AtomicU8 as serde::de::Deserialize>::deserialize::<_>
Unexecuted instantiation: <core::sync::atomic::AtomicI64 as serde::de::Deserialize>::deserialize::<_>
Unexecuted instantiation: <core::sync::atomic::AtomicBool as serde::de::Deserialize>::deserialize::<_>
Unexecuted instantiation: <core::sync::atomic::AtomicIsize as serde::de::Deserialize>::deserialize::<_>
Unexecuted instantiation: <core::sync::atomic::AtomicUsize as serde::de::Deserialize>::deserialize::<_>
Unexecuted instantiation: <core::sync::atomic::AtomicI32 as serde::de::Deserialize>::deserialize::<_>
Unexecuted instantiation: <core::sync::atomic::AtomicU16 as serde::de::Deserialize>::deserialize::<_>
Unexecuted instantiation: <core::sync::atomic::AtomicI16 as serde::de::Deserialize>::deserialize::<_>
Unexecuted instantiation: <core::sync::atomic::AtomicU32 as serde::de::Deserialize>::deserialize::<_>
Unexecuted instantiation: <core::sync::atomic::AtomicU64 as serde::de::Deserialize>::deserialize::<_>
Unexecuted instantiation: <core::sync::atomic::AtomicI8 as serde::de::Deserialize>::deserialize::<_>
2678
            }
2679
        )*
2680
    };
2681
}
2682
2683
#[cfg(all(feature = "std", not(no_std_atomic)))]
2684
atomic_impl! {
2685
    AtomicBool "8"
2686
    AtomicI8 "8"
2687
    AtomicI16 "16"
2688
    AtomicI32 "32"
2689
    AtomicIsize "ptr"
2690
    AtomicU8 "8"
2691
    AtomicU16 "16"
2692
    AtomicU32 "32"
2693
    AtomicUsize "ptr"
2694
}
2695
2696
#[cfg(all(feature = "std", not(no_std_atomic64)))]
2697
atomic_impl! {
2698
    AtomicI64 "64"
2699
    AtomicU64 "64"
2700
}
2701
2702
#[cfg(feature = "std")]
2703
struct FromStrVisitor<T> {
2704
    expecting: &'static str,
2705
    ty: PhantomData<T>,
2706
}
2707
2708
#[cfg(feature = "std")]
2709
impl<T> FromStrVisitor<T> {
2710
0
    fn new(expecting: &'static str) -> Self {
2711
0
        FromStrVisitor {
2712
0
            expecting: expecting,
2713
0
            ty: PhantomData,
2714
0
        }
2715
0
    }
2716
}
2717
2718
#[cfg(feature = "std")]
2719
impl<'de, T> Visitor<'de> for FromStrVisitor<T>
2720
where
2721
    T: str::FromStr,
2722
    T::Err: fmt::Display,
2723
{
2724
    type Value = T;
2725
2726
0
    fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
2727
0
        formatter.write_str(self.expecting)
2728
0
    }
2729
2730
0
    fn visit_str<E>(self, s: &str) -> Result<Self::Value, E>
2731
0
    where
2732
0
        E: Error,
2733
0
    {
2734
0
        s.parse().map_err(Error::custom)
2735
0
    }
2736
}