One macro to deserialize all atomics
This commit is contained in:
parent
d55a4a279f
commit
85ae57040d
@ -2548,48 +2548,23 @@ 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 {
|
$(
|
||||||
#[inline]
|
impl<'de> Deserialize<'de> for $ty {
|
||||||
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>,
|
||||||
{
|
{
|
||||||
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);
|
|
||||||
|
Loading…
Reference in New Issue
Block a user