From 228b5a4a63dbc60a702734895ec563358e519ad2 Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Mon, 6 Aug 2018 22:47:50 -0700 Subject: [PATCH] Provide ops::Range impls whether or not std is used --- serde/src/de/impls.rs | 13 +++++-------- serde/src/lib.rs | 3 ++- serde/src/ser/impls.rs | 3 +-- 3 files changed, 8 insertions(+), 11 deletions(-) diff --git a/serde/src/de/impls.rs b/serde/src/de/impls.rs index 39a8cf4e..5ab6773d 100644 --- a/serde/src/de/impls.rs +++ b/serde/src/de/impls.rs @@ -9,12 +9,10 @@ use lib::*; use de::{ - Deserialize, Deserializer, EnumAccess, Error, SeqAccess, Unexpected, VariantAccess, Visitor, + Deserialize, Deserializer, EnumAccess, Error, MapAccess, SeqAccess, Unexpected, VariantAccess, + Visitor, }; -#[cfg(any(core_duration, feature = "std", feature = "alloc"))] -use de::MapAccess; - use de::from_primitive::FromPrimitive; use private::de::InPlaceSeed; @@ -2054,8 +2052,7 @@ impl<'de> Deserialize<'de> for SystemTime { // start: u64, // end: u32, // } -#[cfg(feature = "std")] -impl<'de, Idx> Deserialize<'de> for ops::Range +impl<'de, Idx> Deserialize<'de> for Range where Idx: Deserialize<'de>, { @@ -2105,7 +2102,7 @@ where b"start" => Ok(Field::Start), b"end" => Ok(Field::End), _ => { - let value = String::from_utf8_lossy(value); + let value = ::export::from_utf8_lossy(value); Err(Error::unknown_field(&value, FIELDS)) } } @@ -2124,7 +2121,7 @@ where where Idx: Deserialize<'de>, { - type Value = ops::Range; + type Value = Range; fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { formatter.write_str("struct Range") diff --git a/serde/src/lib.rs b/serde/src/lib.rs index 79fd5b7b..3c72b01c 100644 --- a/serde/src/lib.rs +++ b/serde/src/lib.rs @@ -155,7 +155,7 @@ mod lib { pub use std::*; } - pub use self::core::{cmp, iter, mem, num, ops, slice, str}; + pub use self::core::{cmp, iter, mem, num, slice, str}; pub use self::core::{f32, f64}; pub use self::core::{i16, i32, i64, i8, isize}; pub use self::core::{u16, u32, u64, u8, usize}; @@ -166,6 +166,7 @@ mod lib { pub use self::core::default::{self, Default}; pub use self::core::fmt::{self, Debug, Display}; pub use self::core::marker::{self, PhantomData}; + pub use self::core::ops::Range; pub use self::core::option::{self, Option}; pub use self::core::result::{self, Result}; diff --git a/serde/src/ser/impls.rs b/serde/src/ser/impls.rs index 624d07a5..5a1952e4 100644 --- a/serde/src/ser/impls.rs +++ b/serde/src/ser/impls.rs @@ -227,8 +227,7 @@ seq_impl!(VecDeque); //////////////////////////////////////////////////////////////////////////////// -#[cfg(feature = "std")] -impl Serialize for ops::Range +impl Serialize for Range where Idx: Serialize, {