impl Serialize and Deserialize for core::cmp::Reverse

This commit is contained in:
Artem Vorotnikov 2019-02-20 04:30:53 +03:00
parent bf27b28554
commit f3ffcfd61e
No known key found for this signature in database
GPG Key ID: E0148C3F2FBB7A20
3 changed files with 16 additions and 0 deletions

View File

@ -578,6 +578,8 @@ macro_rules! forwarded_impl {
#[cfg(all(feature = "std", de_boxed_c_str))] #[cfg(all(feature = "std", de_boxed_c_str))]
forwarded_impl!((), Box<CStr>, CString::into_boxed_c_str); forwarded_impl!((), Box<CStr>, CString::into_boxed_c_str);
forwarded_impl!((T), Reverse<T>, Reverse);
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
struct OptionVisitor<T> { struct OptionVisitor<T> {

View File

@ -139,6 +139,7 @@ mod lib {
pub use self::core::cell::{Cell, RefCell}; pub use self::core::cell::{Cell, RefCell};
pub use self::core::clone::{self, Clone}; pub use self::core::clone::{self, Clone};
pub use self::core::cmp::Reverse;
pub use self::core::convert::{self, From, Into}; pub use self::core::convert::{self, From, Into};
pub use self::core::default::{self, Default}; pub use self::core::default::{self, Default};
pub use self::core::fmt::{self, Debug, Display}; pub use self::core::fmt::{self, Debug, Display};

View File

@ -824,3 +824,16 @@ where
self.0.serialize(serializer) self.0.serialize(serializer)
} }
} }
impl<T> Serialize for Reverse<T>
where
T: Serialize,
{
#[inline]
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: Serializer,
{
self.0.serialize(serializer)
}
}