One macro to deserialize all atomics

This commit is contained in:
David Tolnay 2019-07-16 07:46:44 -07:00
parent d55a4a279f
commit 85ae57040d
No known key found for this signature in database
GPG Key ID: F9BA143B95FF6D82

View File

@ -2548,9 +2548,9 @@ where
#[cfg(all(feature = "std", std_integer_atomics))] #[cfg(all(feature = "std", std_integer_atomics))]
macro_rules! atomic_impl { macro_rules! atomic_impl {
($ty:ident) => { ($($ty:ident)*) => {
$(
impl<'de> Deserialize<'de> for $ty { impl<'de> Deserialize<'de> for $ty {
#[inline]
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where where
D: Deserializer<'de>, D: Deserializer<'de>,
@ -2558,38 +2558,13 @@ macro_rules! atomic_impl {
Deserialize::deserialize(deserializer).map(Self::new) Deserialize::deserialize(deserializer).map(Self::new)
} }
} }
)*
}; };
} }
#[cfg(all(feature = "std", std_integer_atomics))] #[cfg(all(feature = "std", std_integer_atomics))]
atomic_impl!(AtomicBool); atomic_impl! {
AtomicBool
#[cfg(all(feature = "std", std_integer_atomics))] AtomicI8 AtomicI16 AtomicI32 AtomicI64 AtomicIsize
atomic_impl!(AtomicI8); AtomicU8 AtomicU16 AtomicU32 AtomicU64 AtomicUsize
}
#[cfg(all(feature = "std", std_integer_atomics))]
atomic_impl!(AtomicI16);
#[cfg(all(feature = "std", std_integer_atomics))]
atomic_impl!(AtomicI32);
#[cfg(all(feature = "std", std_integer_atomics))]
atomic_impl!(AtomicI64);
#[cfg(all(feature = "std", std_integer_atomics))]
atomic_impl!(AtomicIsize);
#[cfg(all(feature = "std", std_integer_atomics))]
atomic_impl!(AtomicU8);
#[cfg(all(feature = "std", std_integer_atomics))]
atomic_impl!(AtomicU16);
#[cfg(all(feature = "std", std_integer_atomics))]
atomic_impl!(AtomicU32);
#[cfg(all(feature = "std", std_integer_atomics))]
atomic_impl!(AtomicU64);
#[cfg(all(feature = "std", std_integer_atomics))]
atomic_impl!(AtomicUsize);