Merge pull request #1486 from vorot93/reverse
impl Serialize and Deserialize for core::cmp::Reverse
This commit is contained in:
commit
97920be33a
@ -23,6 +23,12 @@ fn main() {
|
|||||||
println!("cargo:rustc-cfg=collections_bound");
|
println!("cargo:rustc-cfg=collections_bound");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// core::cmp::Reverse stabilized in Rust 1.19:
|
||||||
|
// https://doc.rust-lang.org/stable/core/cmp/struct.Reverse.html
|
||||||
|
if minor >= 19 {
|
||||||
|
println!("cargo:rustc-cfg=core_reverse");
|
||||||
|
}
|
||||||
|
|
||||||
// CString::into_boxed_c_str stabilized in Rust 1.20:
|
// CString::into_boxed_c_str stabilized in Rust 1.20:
|
||||||
// https://doc.rust-lang.org/std/ffi/struct.CString.html#method.into_boxed_c_str
|
// https://doc.rust-lang.org/std/ffi/struct.CString.html#method.into_boxed_c_str
|
||||||
if minor >= 20 {
|
if minor >= 20 {
|
||||||
|
@ -578,6 +578,9 @@ 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);
|
||||||
|
|
||||||
|
#[cfg(core_reverse)]
|
||||||
|
forwarded_impl!((T), Reverse<T>, Reverse);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
struct OptionVisitor<T> {
|
struct OptionVisitor<T> {
|
||||||
|
@ -139,6 +139,8 @@ 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};
|
||||||
|
#[cfg(core_reverse)]
|
||||||
|
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};
|
||||||
|
@ -824,3 +824,17 @@ where
|
|||||||
self.0.serialize(serializer)
|
self.0.serialize(serializer)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(core_reverse)]
|
||||||
|
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)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user