summaryrefslogtreecommitdiffstats
path: root/vendor/serde/src/de/impls.rs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 18:31:44 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 18:31:44 +0000
commitc23a457e72abe608715ac76f076f47dc42af07a5 (patch)
tree2772049aaf84b5c9d0ed12ec8d86812f7a7904b6 /vendor/serde/src/de/impls.rs
parentReleasing progress-linux version 1.73.0+dfsg1-1~progress7.99u1. (diff)
downloadrustc-c23a457e72abe608715ac76f076f47dc42af07a5.tar.xz
rustc-c23a457e72abe608715ac76f076f47dc42af07a5.zip
Merging upstream version 1.74.1+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/serde/src/de/impls.rs')
-rw-r--r--vendor/serde/src/de/impls.rs286
1 files changed, 121 insertions, 165 deletions
diff --git a/vendor/serde/src/de/impls.rs b/vendor/serde/src/de/impls.rs
index 12fbdfdb3..fbee1554b 100644
--- a/vendor/serde/src/de/impls.rs
+++ b/vendor/serde/src/de/impls.rs
@@ -1,16 +1,14 @@
-use lib::*;
+use crate::lib::*;
-use de::{
- Deserialize, Deserializer, EnumAccess, Error, SeqAccess, Unexpected, VariantAccess, Visitor,
+use crate::de::{
+ Deserialize, Deserializer, EnumAccess, Error, MapAccess, SeqAccess, Unexpected, VariantAccess,
+ Visitor,
};
-#[cfg(any(feature = "std", feature = "alloc", not(no_core_duration)))]
-use de::MapAccess;
-
-use seed::InPlaceSeed;
+use crate::seed::InPlaceSeed;
#[cfg(any(feature = "std", feature = "alloc"))]
-use __private::size_hint;
+use crate::de::size_hint;
////////////////////////////////////////////////////////////////////////////////
@@ -84,7 +82,7 @@ macro_rules! impl_deserialize_num {
($primitive:ident, $nonzero:ident $(cfg($($cfg:tt)*))*, $deserialize:ident $($method:ident!($($val:ident : $visit:ident)*);)*) => {
impl_deserialize_num!($primitive, $deserialize $($method!($($val : $visit)*);)*);
- #[cfg(all(not(no_num_nonzero), $($($cfg)*)*))]
+ $(#[cfg($($cfg)*)])*
impl<'de> Deserialize<'de> for num::$nonzero {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
@@ -366,64 +364,62 @@ impl_deserialize_num! {
num_as_self!(u8:visit_u8 u16:visit_u16 u32:visit_u32 u64:visit_u64);
}
-serde_if_integer128! {
- macro_rules! num_128 {
- ($ty:ident : $visit:ident) => {
- fn $visit<E>(self, v: $ty) -> Result<Self::Value, E>
- where
- E: Error,
+macro_rules! num_128 {
+ ($ty:ident : $visit:ident) => {
+ fn $visit<E>(self, v: $ty) -> Result<Self::Value, E>
+ where
+ E: Error,
+ {
+ if v as i128 >= Self::Value::min_value() as i128
+ && v as u128 <= Self::Value::max_value() as u128
{
- if v as i128 >= Self::Value::min_value() as i128
- && v as u128 <= Self::Value::max_value() as u128
- {
- Ok(v as Self::Value)
- } else {
- Err(Error::invalid_value(
- Unexpected::Other(stringify!($ty)),
- &self,
- ))
- }
+ Ok(v as Self::Value)
+ } else {
+ Err(Error::invalid_value(
+ Unexpected::Other(stringify!($ty)),
+ &self,
+ ))
}
- };
+ }
+ };
- (nonzero $primitive:ident $ty:ident : $visit:ident) => {
- fn $visit<E>(self, v: $ty) -> Result<Self::Value, E>
- where
- E: Error,
+ (nonzero $primitive:ident $ty:ident : $visit:ident) => {
+ fn $visit<E>(self, v: $ty) -> Result<Self::Value, E>
+ where
+ E: Error,
+ {
+ if v as i128 >= $primitive::min_value() as i128
+ && v as u128 <= $primitive::max_value() as u128
{
- if v as i128 >= $primitive::min_value() as i128
- && v as u128 <= $primitive::max_value() as u128
- {
- if let Some(nonzero) = Self::Value::new(v as $primitive) {
- Ok(nonzero)
- } else {
- Err(Error::invalid_value(Unexpected::Unsigned(0), &self))
- }
+ if let Some(nonzero) = Self::Value::new(v as $primitive) {
+ Ok(nonzero)
} else {
- Err(Error::invalid_value(
- Unexpected::Other(stringify!($ty)),
- &self,
- ))
+ Err(Error::invalid_value(Unexpected::Unsigned(0), &self))
}
+ } else {
+ Err(Error::invalid_value(
+ Unexpected::Other(stringify!($ty)),
+ &self,
+ ))
}
- };
- }
+ }
+ };
+}
- impl_deserialize_num! {
- i128, NonZeroI128 cfg(not(no_num_nonzero_signed)), deserialize_i128
- num_self!(i128:visit_i128);
- num_as_self!(i8:visit_i8 i16:visit_i16 i32:visit_i32 i64:visit_i64);
- num_as_self!(u8:visit_u8 u16:visit_u16 u32:visit_u32 u64:visit_u64);
- num_128!(u128:visit_u128);
- }
+impl_deserialize_num! {
+ i128, NonZeroI128 cfg(not(no_num_nonzero_signed)), deserialize_i128
+ num_self!(i128:visit_i128);
+ num_as_self!(i8:visit_i8 i16:visit_i16 i32:visit_i32 i64:visit_i64);
+ num_as_self!(u8:visit_u8 u16:visit_u16 u32:visit_u32 u64:visit_u64);
+ num_128!(u128:visit_u128);
+}
- impl_deserialize_num! {
- u128, NonZeroU128, deserialize_u128
- num_self!(u128:visit_u128);
- num_as_self!(u8:visit_u8 u16:visit_u16 u32:visit_u32 u64:visit_u64);
- int_to_uint!(i8:visit_i8 i16:visit_i16 i32:visit_i32 i64:visit_i64);
- num_128!(i128:visit_i128);
- }
+impl_deserialize_num! {
+ u128, NonZeroU128, deserialize_u128
+ num_self!(u128:visit_u128);
+ num_as_self!(u8:visit_u8 u16:visit_u16 u32:visit_u32 u64:visit_u64);
+ int_to_uint!(i8:visit_i8 i16:visit_i16 i32:visit_i32 i64:visit_i64);
+ num_128!(i128:visit_i128);
}
////////////////////////////////////////////////////////////////////////////////
@@ -684,7 +680,7 @@ impl<'de> Visitor<'de> for CStringVisitor {
let capacity = size_hint::cautious::<u8>(seq.size_hint());
let mut values = Vec::<u8>::with_capacity(capacity);
- while let Some(value) = try!(seq.next_element()) {
+ while let Some(value) = tri!(seq.next_element()) {
values.push(value);
}
@@ -747,13 +743,9 @@ macro_rules! forwarded_impl {
}
}
-#[cfg(all(
- any(feature = "std", all(not(no_core_cstr), feature = "alloc")),
- not(no_de_boxed_c_str)
-))]
+#[cfg(any(feature = "std", all(not(no_core_cstr), feature = "alloc")))]
forwarded_impl!((), Box<CStr>, CString::into_boxed_c_str);
-#[cfg(not(no_core_reverse))]
forwarded_impl!((T), Reverse<T>, Reverse);
////////////////////////////////////////////////////////////////////////////////
@@ -901,7 +893,7 @@ macro_rules! seq_impl {
{
let mut values = $with_capacity;
- while let Some(value) = try!($access.next_element()) {
+ while let Some(value) = tri!($access.next_element()) {
$insert(&mut values, value);
}
@@ -939,7 +931,7 @@ macro_rules! seq_impl {
$reserve(&mut self.0, size_hint::cautious::<T>($access.size_hint()));
// FIXME: try to overwrite old values here? (Vec, VecDeque, LinkedList)
- while let Some(value) = try!($access.next_element()) {
+ while let Some(value) = tri!($access.next_element()) {
$insert(&mut self.0, value);
}
@@ -1039,7 +1031,7 @@ where
let capacity = size_hint::cautious::<T>(seq.size_hint());
let mut values = Vec::<T>::with_capacity(capacity);
- while let Some(value) = try!(seq.next_element()) {
+ while let Some(value) = tri!(seq.next_element()) {
values.push(value);
}
@@ -1081,7 +1073,7 @@ where
for i in 0..self.0.len() {
let next = {
let next_place = InPlaceSeed(&mut self.0[i]);
- try!(seq.next_element_seed(next_place))
+ tri!(seq.next_element_seed(next_place))
};
if next.is_none() {
self.0.truncate(i);
@@ -1089,7 +1081,7 @@ where
}
}
- while let Some(value) = try!(seq.next_element()) {
+ while let Some(value) = tri!(seq.next_element()) {
self.0.push(value);
}
@@ -1161,7 +1153,7 @@ macro_rules! array_impls {
A: SeqAccess<'de>,
{
Ok([$(
- match try!(seq.next_element()) {
+ match tri!(seq.next_element()) {
Some(val) => val,
None => return Err(Error::invalid_length($n, &self)),
}
@@ -1186,7 +1178,7 @@ macro_rules! array_impls {
{
let mut fail_idx = None;
for (idx, dest) in self.0[..].iter_mut().enumerate() {
- if try!(seq.next_element_seed(InPlaceSeed(dest))).is_none() {
+ if tri!(seq.next_element_seed(InPlaceSeed(dest))).is_none() {
fail_idx = Some(idx);
break;
}
@@ -1284,7 +1276,7 @@ macro_rules! tuple_impls {
A: SeqAccess<'de>,
{
$(
- let $name = match try!(seq.next_element()) {
+ let $name = match tri!(seq.next_element()) {
Some(value) => value,
None => return Err(Error::invalid_length($n, &self)),
};
@@ -1318,7 +1310,7 @@ macro_rules! tuple_impls {
A: SeqAccess<'de>,
{
$(
- if try!(seq.next_element_seed(InPlaceSeed(&mut (self.0).$n))).is_none() {
+ if tri!(seq.next_element_seed(InPlaceSeed(&mut (self.0).$n))).is_none() {
return Err(Error::invalid_length($n, &self));
}
)+
@@ -1395,7 +1387,7 @@ macro_rules! map_impl {
{
let mut values = $with_capacity;
- while let Some((key, value)) = try!($access.next_entry()) {
+ while let Some((key, value)) = tri!($access.next_entry()) {
values.insert(key, value);
}
@@ -1541,7 +1533,7 @@ macro_rules! deserialize_enum {
where
A: EnumAccess<'de>,
{
- match try!(data.variant()) {
+ match tri!(data.variant()) {
$(
($name_kind :: $variant, v) => v.newtype_variant().map($name :: $variant),
)*
@@ -1561,7 +1553,7 @@ impl<'de> Deserialize<'de> for net::IpAddr {
if deserializer.is_human_readable() {
deserializer.deserialize_str(FromStrVisitor::new("IP address"))
} else {
- use lib::net::IpAddr;
+ use crate::lib::net::IpAddr;
deserialize_enum! {
IpAddr IpAddrKind (V4; b"V4"; 0, V6; b"V6"; 1)
"`V4` or `V6`",
@@ -1604,7 +1596,7 @@ impl<'de> Deserialize<'de> for net::SocketAddr {
if deserializer.is_human_readable() {
deserializer.deserialize_str(FromStrVisitor::new("socket address"))
} else {
- use lib::net::SocketAddr;
+ use crate::lib::net::SocketAddr;
deserialize_enum! {
SocketAddr SocketAddrKind (V4; b"V4"; 0, V6; b"V6"; 1)
"`V4` or `V6`",
@@ -1714,7 +1706,7 @@ impl<'de> Deserialize<'de> for PathBuf {
}
}
-#[cfg(all(feature = "std", not(no_de_boxed_path)))]
+#[cfg(feature = "std")]
forwarded_impl!((), Box<Path>, PathBuf::into_boxed_path);
////////////////////////////////////////////////////////////////////////////////
@@ -1748,7 +1740,7 @@ impl<'de> Visitor<'de> for OsStringVisitor {
{
use std::os::unix::ffi::OsStringExt;
- match try!(data.variant()) {
+ match tri!(data.variant()) {
(OsStringKind::Unix, v) => v.newtype_variant().map(OsString::from_vec),
(OsStringKind::Windows, _) => Err(Error::custom(
"cannot deserialize Windows OS string on Unix",
@@ -1763,7 +1755,7 @@ impl<'de> Visitor<'de> for OsStringVisitor {
{
use std::os::windows::ffi::OsStringExt;
- match try!(data.variant()) {
+ match tri!(data.variant()) {
(OsStringKind::Windows, v) => v
.newtype_variant::<Vec<u16>>()
.map(|vec| OsString::from_wide(&vec)),
@@ -1795,29 +1787,8 @@ forwarded_impl!((T), Box<[T]>, Vec::into_boxed_slice);
#[cfg(any(feature = "std", feature = "alloc"))]
forwarded_impl!((), Box<str>, String::into_boxed_str);
-#[cfg(all(no_de_rc_dst, feature = "rc", any(feature = "std", feature = "alloc")))]
-forwarded_impl! {
- /// This impl requires the [`"rc"`] Cargo feature of Serde.
- ///
- /// Deserializing a data structure containing `Arc` will not attempt to
- /// deduplicate `Arc` references to the same data. Every deserialized `Arc`
- /// will end up with a strong count of 1.
- ///
- /// [`"rc"`]: https://serde.rs/feature-flags.html#-features-rc
- (T), Arc<T>, Arc::new
-}
-
-#[cfg(all(no_de_rc_dst, feature = "rc", any(feature = "std", feature = "alloc")))]
-forwarded_impl! {
- /// This impl requires the [`"rc"`] Cargo feature of Serde.
- ///
- /// Deserializing a data structure containing `Rc` will not attempt to
- /// deduplicate `Rc` references to the same data. Every deserialized `Rc`
- /// will end up with a strong count of 1.
- ///
- /// [`"rc"`]: https://serde.rs/feature-flags.html#-features-rc
- (T), Rc<T>, Rc::new
-}
+#[cfg(all(feature = "std", any(unix, windows)))]
+forwarded_impl!((), Box<OsStr>, OsString::into_boxed_os_str);
#[cfg(any(feature = "std", feature = "alloc"))]
impl<'de, 'a, T: ?Sized> Deserialize<'de> for Cow<'a, T>
@@ -1849,7 +1820,7 @@ where
where
D: Deserializer<'de>,
{
- try!(Option::<T>::deserialize(deserializer));
+ tri!(Option::<T>::deserialize(deserializer));
Ok(RcWeak::new())
}
}
@@ -1867,18 +1838,14 @@ where
where
D: Deserializer<'de>,
{
- try!(Option::<T>::deserialize(deserializer));
+ tri!(Option::<T>::deserialize(deserializer));
Ok(ArcWeak::new())
}
}
////////////////////////////////////////////////////////////////////////////////
-#[cfg(all(
- not(no_de_rc_dst),
- feature = "rc",
- any(feature = "std", feature = "alloc")
-))]
+#[cfg(all(feature = "rc", any(feature = "std", feature = "alloc")))]
macro_rules! box_forwarded_impl {
(
$(#[doc = $doc:tt])*
@@ -1899,11 +1866,7 @@ macro_rules! box_forwarded_impl {
};
}
-#[cfg(all(
- not(no_de_rc_dst),
- feature = "rc",
- any(feature = "std", feature = "alloc")
-))]
+#[cfg(all(feature = "rc", any(feature = "std", feature = "alloc")))]
box_forwarded_impl! {
/// This impl requires the [`"rc"`] Cargo feature of Serde.
///
@@ -1915,11 +1878,7 @@ box_forwarded_impl! {
Rc
}
-#[cfg(all(
- not(no_de_rc_dst),
- feature = "rc",
- any(feature = "std", feature = "alloc")
-))]
+#[cfg(all(feature = "rc", any(feature = "std", feature = "alloc")))]
box_forwarded_impl! {
/// This impl requires the [`"rc"`] Cargo feature of Serde.
///
@@ -1963,7 +1922,6 @@ forwarded_impl!((T), RwLock<T>, RwLock::new);
// secs: u64,
// nanos: u32,
// }
-#[cfg(any(feature = "std", not(no_core_duration)))]
impl<'de> Deserialize<'de> for Duration {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
@@ -2011,7 +1969,7 @@ impl<'de> Deserialize<'de> for Duration {
b"secs" => Ok(Field::Secs),
b"nanos" => Ok(Field::Nanos),
_ => {
- let value = ::__private::from_utf8_lossy(value);
+ let value = crate::__private::from_utf8_lossy(value);
Err(Error::unknown_field(&*value, FIELDS))
}
}
@@ -2046,19 +2004,19 @@ impl<'de> Deserialize<'de> for Duration {
where
A: SeqAccess<'de>,
{
- let secs: u64 = match try!(seq.next_element()) {
+ let secs: u64 = match tri!(seq.next_element()) {
Some(value) => value,
None => {
return Err(Error::invalid_length(0, &self));
}
};
- let nanos: u32 = match try!(seq.next_element()) {
+ let nanos: u32 = match tri!(seq.next_element()) {
Some(value) => value,
None => {
return Err(Error::invalid_length(1, &self));
}
};
- try!(check_overflow(secs, nanos));
+ tri!(check_overflow(secs, nanos));
Ok(Duration::new(secs, nanos))
}
@@ -2068,19 +2026,19 @@ impl<'de> Deserialize<'de> for Duration {
{
let mut secs: Option<u64> = None;
let mut nanos: Option<u32> = None;
- while let Some(key) = try!(map.next_key()) {
+ while let Some(key) = tri!(map.next_key()) {
match key {
Field::Secs => {
if secs.is_some() {
return Err(<A::Error as Error>::duplicate_field("secs"));
}
- secs = Some(try!(map.next_value()));
+ secs = Some(tri!(map.next_value()));
}
Field::Nanos => {
if nanos.is_some() {
return Err(<A::Error as Error>::duplicate_field("nanos"));
}
- nanos = Some(try!(map.next_value()));
+ nanos = Some(tri!(map.next_value()));
}
}
}
@@ -2092,7 +2050,7 @@ impl<'de> Deserialize<'de> for Duration {
Some(nanos) => nanos,
None => return Err(<A::Error as Error>::missing_field("nanos")),
};
- try!(check_overflow(secs, nanos));
+ tri!(check_overflow(secs, nanos));
Ok(Duration::new(secs, nanos))
}
}
@@ -2184,19 +2142,19 @@ impl<'de> Deserialize<'de> for SystemTime {
where
A: SeqAccess<'de>,
{
- let secs: u64 = match try!(seq.next_element()) {
+ let secs: u64 = match tri!(seq.next_element()) {
Some(value) => value,
None => {
return Err(Error::invalid_length(0, &self));
}
};
- let nanos: u32 = match try!(seq.next_element()) {
+ let nanos: u32 = match tri!(seq.next_element()) {
Some(value) => value,
None => {
return Err(Error::invalid_length(1, &self));
}
};
- try!(check_overflow(secs, nanos));
+ tri!(check_overflow(secs, nanos));
Ok(Duration::new(secs, nanos))
}
@@ -2206,7 +2164,7 @@ impl<'de> Deserialize<'de> for SystemTime {
{
let mut secs: Option<u64> = None;
let mut nanos: Option<u32> = None;
- while let Some(key) = try!(map.next_key()) {
+ while let Some(key) = tri!(map.next_key()) {
match key {
Field::Secs => {
if secs.is_some() {
@@ -2214,7 +2172,7 @@ impl<'de> Deserialize<'de> for SystemTime {
"secs_since_epoch",
));
}
- secs = Some(try!(map.next_value()));
+ secs = Some(tri!(map.next_value()));
}
Field::Nanos => {
if nanos.is_some() {
@@ -2222,7 +2180,7 @@ impl<'de> Deserialize<'de> for SystemTime {
"nanos_since_epoch",
));
}
- nanos = Some(try!(map.next_value()));
+ nanos = Some(tri!(map.next_value()));
}
}
}
@@ -2234,13 +2192,13 @@ impl<'de> Deserialize<'de> for SystemTime {
Some(nanos) => nanos,
None => return Err(<A::Error as Error>::missing_field("nanos_since_epoch")),
};
- try!(check_overflow(secs, nanos));
+ tri!(check_overflow(secs, nanos));
Ok(Duration::new(secs, nanos))
}
}
const FIELDS: &[&str] = &["secs_since_epoch", "nanos_since_epoch"];
- let duration = try!(deserializer.deserialize_struct("SystemTime", FIELDS, DurationVisitor));
+ let duration = tri!(deserializer.deserialize_struct("SystemTime", FIELDS, DurationVisitor));
#[cfg(not(no_systemtime_checked_add))]
let ret = UNIX_EPOCH
.checked_add(duration)
@@ -2269,7 +2227,7 @@ where
where
D: Deserializer<'de>,
{
- let (start, end) = try!(deserializer.deserialize_struct(
+ let (start, end) = tri!(deserializer.deserialize_struct(
"Range",
range::FIELDS,
range::RangeVisitor {
@@ -2281,7 +2239,6 @@ where
}
}
-#[cfg(not(no_range_inclusive))]
impl<'de, Idx> Deserialize<'de> for RangeInclusive<Idx>
where
Idx: Deserialize<'de>,
@@ -2290,7 +2247,7 @@ where
where
D: Deserializer<'de>,
{
- let (start, end) = try!(deserializer.deserialize_struct(
+ let (start, end) = tri!(deserializer.deserialize_struct(
"RangeInclusive",
range::FIELDS,
range::RangeVisitor {
@@ -2303,9 +2260,9 @@ where
}
mod range {
- use lib::*;
+ use crate::lib::*;
- use de::{Deserialize, Deserializer, Error, MapAccess, SeqAccess, Visitor};
+ use crate::de::{Deserialize, Deserializer, Error, MapAccess, SeqAccess, Visitor};
pub const FIELDS: &[&str] = &["start", "end"];
@@ -2351,7 +2308,7 @@ mod range {
b"start" => Ok(Field::Start),
b"end" => Ok(Field::End),
_ => {
- let value = ::__private::from_utf8_lossy(value);
+ let value = crate::__private::from_utf8_lossy(value);
Err(Error::unknown_field(&*value, FIELDS))
}
}
@@ -2381,13 +2338,13 @@ mod range {
where
A: SeqAccess<'de>,
{
- let start: Idx = match try!(seq.next_element()) {
+ let start: Idx = match tri!(seq.next_element()) {
Some(value) => value,
None => {
return Err(Error::invalid_length(0, &self));
}
};
- let end: Idx = match try!(seq.next_element()) {
+ let end: Idx = match tri!(seq.next_element()) {
Some(value) => value,
None => {
return Err(Error::invalid_length(1, &self));
@@ -2402,19 +2359,19 @@ mod range {
{
let mut start: Option<Idx> = None;
let mut end: Option<Idx> = None;
- while let Some(key) = try!(map.next_key()) {
+ while let Some(key) = tri!(map.next_key()) {
match key {
Field::Start => {
if start.is_some() {
return Err(<A::Error as Error>::duplicate_field("start"));
}
- start = Some(try!(map.next_value()));
+ start = Some(tri!(map.next_value()));
}
Field::End => {
if end.is_some() {
return Err(<A::Error as Error>::duplicate_field("end"));
}
- end = Some(try!(map.next_value()));
+ end = Some(tri!(map.next_value()));
}
}
}
@@ -2448,7 +2405,7 @@ where
where
D: Deserializer<'de>,
{
- let start = try!(deserializer.deserialize_struct(
+ let start = tri!(deserializer.deserialize_struct(
"RangeFrom",
range_from::FIELDS,
range_from::RangeFromVisitor {
@@ -2461,9 +2418,9 @@ where
}
mod range_from {
- use lib::*;
+ use crate::lib::*;
- use de::{Deserialize, Deserializer, Error, MapAccess, SeqAccess, Visitor};
+ use crate::de::{Deserialize, Deserializer, Error, MapAccess, SeqAccess, Visitor};
pub const FIELDS: &[&str] = &["end"];
@@ -2506,7 +2463,7 @@ mod range_from {
match value {
b"end" => Ok(Field::End),
_ => {
- let value = ::__private::from_utf8_lossy(value);
+ let value = crate::__private::from_utf8_lossy(value);
Err(Error::unknown_field(&*value, FIELDS))
}
}
@@ -2536,7 +2493,7 @@ mod range_from {
where
A: SeqAccess<'de>,
{
- let end: Idx = match try!(seq.next_element()) {
+ let end: Idx = match tri!(seq.next_element()) {
Some(value) => value,
None => {
return Err(Error::invalid_length(0, &self));
@@ -2550,13 +2507,13 @@ mod range_from {
A: MapAccess<'de>,
{
let mut end: Option<Idx> = None;
- while let Some(key) = try!(map.next_key()) {
+ while let Some(key) = tri!(map.next_key()) {
match key {
Field::End => {
if end.is_some() {
return Err(<A::Error as Error>::duplicate_field("end"));
}
- end = Some(try!(map.next_value()));
+ end = Some(tri!(map.next_value()));
}
}
}
@@ -2586,7 +2543,7 @@ where
where
D: Deserializer<'de>,
{
- let end = try!(deserializer.deserialize_struct(
+ let end = tri!(deserializer.deserialize_struct(
"RangeTo",
range_to::FIELDS,
range_to::RangeToVisitor {
@@ -2599,9 +2556,9 @@ where
}
mod range_to {
- use lib::*;
+ use crate::lib::*;
- use de::{Deserialize, Deserializer, Error, MapAccess, SeqAccess, Visitor};
+ use crate::de::{Deserialize, Deserializer, Error, MapAccess, SeqAccess, Visitor};
pub const FIELDS: &[&str] = &["start"];
@@ -2644,7 +2601,7 @@ mod range_to {
match value {
b"start" => Ok(Field::Start),
_ => {
- let value = ::__private::from_utf8_lossy(value);
+ let value = crate::__private::from_utf8_lossy(value);
Err(Error::unknown_field(&*value, FIELDS))
}
}
@@ -2674,7 +2631,7 @@ mod range_to {
where
A: SeqAccess<'de>,
{
- let start: Idx = match try!(seq.next_element()) {
+ let start: Idx = match tri!(seq.next_element()) {
Some(value) => value,
None => {
return Err(Error::invalid_length(0, &self));
@@ -2688,13 +2645,13 @@ mod range_to {
A: MapAccess<'de>,
{
let mut start: Option<Idx> = None;
- while let Some(key) = try!(map.next_key()) {
+ while let Some(key) = tri!(map.next_key()) {
match key {
Field::Start => {
if start.is_some() {
return Err(<A::Error as Error>::duplicate_field("start"));
}
- start = Some(try!(map.next_value()));
+ start = Some(tri!(map.next_value()));
}
}
}
@@ -2709,7 +2666,6 @@ mod range_to {
////////////////////////////////////////////////////////////////////////////////
-#[cfg(any(not(no_ops_bound), all(feature = "std", not(no_collections_bound))))]
impl<'de, T> Deserialize<'de> for Bound<T>
where
T: Deserialize<'de>,
@@ -2801,7 +2757,7 @@ where
where
A: EnumAccess<'de>,
{
- match try!(data.variant()) {
+ match tri!(data.variant()) {
(Field::Unbounded, v) => v.unit_variant().map(|()| Bound::Unbounded),
(Field::Included, v) => v.newtype_variant().map(Bound::Included),
(Field::Excluded, v) => v.newtype_variant().map(Bound::Excluded),
@@ -2910,7 +2866,7 @@ where
where
A: EnumAccess<'de>,
{
- match try!(data.variant()) {
+ match tri!(data.variant()) {
(Field::Ok, v) => v.newtype_variant().map(Ok),
(Field::Err, v) => v.newtype_variant().map(Err),
}