Provide ops::Range impls whether or not std is used

This commit is contained in:
David Tolnay 2018-08-06 22:47:50 -07:00
parent 28db9d4989
commit 228b5a4a63
No known key found for this signature in database
GPG Key ID: F9BA143B95FF6D82
3 changed files with 8 additions and 11 deletions

View File

@ -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<Idx>
impl<'de, Idx> Deserialize<'de> for Range<Idx>
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<Idx>;
type Value = Range<Idx>;
fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
formatter.write_str("struct Range")

View File

@ -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};

View File

@ -227,8 +227,7 @@ seq_impl!(VecDeque<T>);
////////////////////////////////////////////////////////////////////////////////
#[cfg(feature = "std")]
impl<Idx> Serialize for ops::Range<Idx>
impl<Idx> Serialize for Range<Idx>
where
Idx: Serialize,
{