Add std::num::Wrapping support

This commit is contained in:
Zoe Juozapaitis 2017-10-31 02:58:41 -07:00
parent aa03fd5d1a
commit eb08f037f5
2 changed files with 33 additions and 0 deletions

View File

@ -1825,3 +1825,20 @@ where
deserializer.deserialize_enum("Result", VARIANTS, ResultVisitor(PhantomData))
}
}
////////////////////////////////////////////////////////////////////////////////
#[cfg(feature = "std")]
use std::num::Wrapping;
#[cfg(feature = "std")]
impl<'de, T> Deserialize<'de> for Wrapping<T>
where
T: Deserialize<'de>
{
fn deserialize<D>(deserializer: D) -> Result<Wrapping<T>, D::Error>
where D: Deserializer<'de>
{
Deserialize::deserialize(deserializer).map(Wrapping)
}
}

View File

@ -664,3 +664,19 @@ impl Serialize for OsString {
self.as_os_str().serialize(serializer)
}
}
////////////////////////////////////////////////////////////////////////////////
#[cfg(feature = "std")]
use std::num::Wrapping;
#[cfg(feature = "std")]
impl<T: Serialize> Serialize for Wrapping<T> {
#[inline]
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: Serializer,
{
self.0.serialize(serializer)
}
}