Coverage Report

Created: 2026-08-14 07:12

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