mirror of
https://github.com/pezkuwichain/serde.git
synced 2026-06-17 19:41:07 +00:00
cleanup some deprecation warnings
This commit is contained in:
+1
-23
@@ -2,10 +2,8 @@
|
|||||||
use core::any::TypeId;
|
use core::any::TypeId;
|
||||||
use core::fmt::{Debug, Display};
|
use core::fmt::{Debug, Display};
|
||||||
|
|
||||||
|
|
||||||
/// A stand-in for `std::error::Error`, which requires no allocation.
|
/// A stand-in for `std::error::Error`, which requires no allocation.
|
||||||
#[cfg(feature = "unstable")]
|
pub trait Error: Debug + Display {
|
||||||
pub trait Error: Debug + Display + ::core::marker::Reflect {
|
|
||||||
/// A short description of the error.
|
/// A short description of the error.
|
||||||
///
|
///
|
||||||
/// The description should not contain newlines or sentence-ending
|
/// The description should not contain newlines or sentence-ending
|
||||||
@@ -22,23 +20,3 @@ pub trait Error: Debug + Display + ::core::marker::Reflect {
|
|||||||
TypeId::of::<Self>()
|
TypeId::of::<Self>()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A stand-in for `std::error::Error`, which requires no allocation.
|
|
||||||
#[cfg(not(feature = "unstable"))]
|
|
||||||
pub trait Error: Debug + Display {
|
|
||||||
/// A short description of the error.
|
|
||||||
///
|
|
||||||
/// The description should not contain newlines or sentence-ending
|
|
||||||
/// punctuation, to facilitate embedding in larger user-facing
|
|
||||||
/// strings.
|
|
||||||
fn description(&self) -> &str;
|
|
||||||
|
|
||||||
/// The lower-level cause of this error, if any.
|
|
||||||
fn cause(&self) -> Option<&Error> { None }
|
|
||||||
|
|
||||||
/// Stubbed! Returns type_id of `()`
|
|
||||||
#[doc(hidden)]
|
|
||||||
fn type_id(&self) -> TypeId where Self: 'static {
|
|
||||||
TypeId::of::<()>()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
+1
-1
@@ -11,7 +11,7 @@
|
|||||||
|
|
||||||
#![doc(html_root_url="https://docs.serde.rs")]
|
#![doc(html_root_url="https://docs.serde.rs")]
|
||||||
#![cfg_attr(not(feature = "std"), no_std)]
|
#![cfg_attr(not(feature = "std"), no_std)]
|
||||||
#![cfg_attr(feature = "unstable", feature(reflect_marker, unicode, nonzero, plugin, step_trait, zero_one))]
|
#![cfg_attr(feature = "unstable", feature(reflect_marker, unicode, nonzero, plugin, step_trait, zero_one, inclusive_range))]
|
||||||
#![cfg_attr(feature = "alloc", feature(alloc))]
|
#![cfg_attr(feature = "alloc", feature(alloc))]
|
||||||
#![cfg_attr(feature = "collections", feature(collections, enumset))]
|
#![cfg_attr(feature = "collections", feature(collections, enumset))]
|
||||||
#![cfg_attr(feature = "clippy", plugin(clippy))]
|
#![cfg_attr(feature = "clippy", plugin(clippy))]
|
||||||
|
|||||||
+20
-4
@@ -324,15 +324,31 @@ impl<T> Serialize for VecDeque<T>
|
|||||||
|
|
||||||
#[cfg(feature = "unstable")]
|
#[cfg(feature = "unstable")]
|
||||||
impl<A> Serialize for ops::Range<A>
|
impl<A> Serialize for ops::Range<A>
|
||||||
where A: Serialize + Clone + iter::Step + num::One,
|
where ops::Range<A>: ExactSizeIterator + iter::Iterator<Item = A> + Clone,
|
||||||
for<'a> &'a A: ops::Add<&'a A, Output = A>,
|
A: Serialize,
|
||||||
{
|
{
|
||||||
#[inline]
|
#[inline]
|
||||||
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
||||||
where S: Serializer,
|
where S: Serializer,
|
||||||
{
|
{
|
||||||
let len = iter::Step::steps_between(&self.start, &self.end, &A::one());
|
let mut seq = try!(serializer.serialize_seq(Some(self.len())));
|
||||||
let mut seq = try!(serializer.serialize_seq(len));
|
for e in self.clone() {
|
||||||
|
try!(seq.serialize_element(e));
|
||||||
|
}
|
||||||
|
seq.end()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "unstable")]
|
||||||
|
impl<A> Serialize for ops::RangeInclusive<A>
|
||||||
|
where ops::RangeInclusive<A>: ExactSizeIterator + iter::Iterator<Item = A> + Clone,
|
||||||
|
A: Serialize,
|
||||||
|
{
|
||||||
|
#[inline]
|
||||||
|
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
||||||
|
where S: Serializer,
|
||||||
|
{
|
||||||
|
let mut seq = try!(serializer.serialize_seq(Some(self.len())));
|
||||||
for e in self.clone() {
|
for e in self.clone() {
|
||||||
try!(seq.serialize_element(e));
|
try!(seq.serialize_element(e));
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user