Format with rustfmt 2019-06-09
This commit is contained in:
parent
a280942f02
commit
102a332616
@ -790,7 +790,8 @@ seq_impl!(
|
||||
BinaryHeap::clear,
|
||||
BinaryHeap::with_capacity(size_hint::cautious(seq.size_hint())),
|
||||
BinaryHeap::reserve,
|
||||
BinaryHeap::push);
|
||||
BinaryHeap::push
|
||||
);
|
||||
|
||||
#[cfg(any(feature = "std", feature = "alloc"))]
|
||||
seq_impl!(
|
||||
@ -799,7 +800,8 @@ seq_impl!(
|
||||
BTreeSet::clear,
|
||||
BTreeSet::new(),
|
||||
nop_reserve,
|
||||
BTreeSet::insert);
|
||||
BTreeSet::insert
|
||||
);
|
||||
|
||||
#[cfg(any(feature = "std", feature = "alloc"))]
|
||||
seq_impl!(
|
||||
@ -2544,55 +2546,54 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(all(feature="std", std_integer_atomics))]
|
||||
#[cfg(all(feature = "std", std_integer_atomics))]
|
||||
use std::sync::atomic;
|
||||
|
||||
|
||||
#[cfg(all(feature="std", std_integer_atomics))]
|
||||
#[cfg(all(feature = "std", std_integer_atomics))]
|
||||
macro_rules! atomic_impl {
|
||||
($ty:path, $primitive:ident) => {
|
||||
impl<'de> Deserialize<'de> for $ty
|
||||
{
|
||||
impl<'de> Deserialize<'de> for $ty {
|
||||
#[inline]
|
||||
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
|
||||
where D: Deserializer<'de>
|
||||
where
|
||||
D: Deserializer<'de>,
|
||||
{
|
||||
let val = $primitive::deserialize(deserializer)?;
|
||||
Ok(Self::new(val))
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#[cfg(all(feature="std", std_integer_atomics))]
|
||||
#[cfg(all(feature = "std", std_integer_atomics))]
|
||||
atomic_impl!(atomic::AtomicBool, bool);
|
||||
|
||||
#[cfg(all(feature="std", std_integer_atomics))]
|
||||
#[cfg(all(feature = "std", std_integer_atomics))]
|
||||
atomic_impl!(atomic::AtomicI8, i8);
|
||||
|
||||
#[cfg(all(feature="std", std_integer_atomics))]
|
||||
#[cfg(all(feature = "std", std_integer_atomics))]
|
||||
atomic_impl!(atomic::AtomicI16, i16);
|
||||
|
||||
#[cfg(all(feature="std", std_integer_atomics))]
|
||||
#[cfg(all(feature = "std", std_integer_atomics))]
|
||||
atomic_impl!(atomic::AtomicI32, i32);
|
||||
|
||||
#[cfg(all(feature="std", std_integer_atomics))]
|
||||
#[cfg(all(feature = "std", std_integer_atomics))]
|
||||
atomic_impl!(atomic::AtomicI64, i64);
|
||||
|
||||
#[cfg(all(feature="std", std_integer_atomics))]
|
||||
#[cfg(all(feature = "std", std_integer_atomics))]
|
||||
atomic_impl!(atomic::AtomicIsize, isize);
|
||||
|
||||
#[cfg(all(feature="std", std_integer_atomics))]
|
||||
#[cfg(all(feature = "std", std_integer_atomics))]
|
||||
atomic_impl!(atomic::AtomicU8, u8);
|
||||
|
||||
#[cfg(all(feature="std", std_integer_atomics))]
|
||||
#[cfg(all(feature = "std", std_integer_atomics))]
|
||||
atomic_impl!(atomic::AtomicU16, u16);
|
||||
|
||||
#[cfg(all(feature="std", std_integer_atomics))]
|
||||
#[cfg(all(feature = "std", std_integer_atomics))]
|
||||
atomic_impl!(atomic::AtomicU32, u32);
|
||||
|
||||
#[cfg(all(feature="std", std_integer_atomics))]
|
||||
#[cfg(all(feature = "std", std_integer_atomics))]
|
||||
atomic_impl!(atomic::AtomicU64, u64);
|
||||
|
||||
#[cfg(all(feature="std", std_integer_atomics))]
|
||||
#[cfg(all(feature = "std", std_integer_atomics))]
|
||||
atomic_impl!(atomic::AtomicUsize, usize);
|
||||
|
@ -841,10 +841,11 @@ where
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
#[cfg(all(feature="std", std_integer_atomics))]
|
||||
|
||||
#[cfg(all(feature = "std", std_integer_atomics))]
|
||||
use std::sync::atomic;
|
||||
|
||||
#[cfg(all(feature="std", std_integer_atomics))]
|
||||
#[cfg(all(feature = "std", std_integer_atomics))]
|
||||
macro_rules! atomic_impl {
|
||||
($ty:path, $method:ident $($cast:tt)*) => {
|
||||
impl Serialize for $ty {
|
||||
@ -859,35 +860,35 @@ macro_rules! atomic_impl {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(all(feature="std", std_integer_atomics))]
|
||||
#[cfg(all(feature = "std", std_integer_atomics))]
|
||||
atomic_impl!(atomic::AtomicBool, serialize_bool);
|
||||
|
||||
#[cfg(all(feature="std", std_integer_atomics))]
|
||||
#[cfg(all(feature = "std", std_integer_atomics))]
|
||||
atomic_impl!(atomic::AtomicI8, serialize_i8);
|
||||
|
||||
#[cfg(all(feature="std", std_integer_atomics))]
|
||||
#[cfg(all(feature = "std", std_integer_atomics))]
|
||||
atomic_impl!(atomic::AtomicI16, serialize_i16);
|
||||
|
||||
#[cfg(all(feature="std", std_integer_atomics))]
|
||||
#[cfg(all(feature = "std", std_integer_atomics))]
|
||||
atomic_impl!(atomic::AtomicI32, serialize_i32);
|
||||
|
||||
#[cfg(all(feature="std", std_integer_atomics))]
|
||||
#[cfg(all(feature = "std", std_integer_atomics))]
|
||||
atomic_impl!(atomic::AtomicI64, serialize_i64);
|
||||
|
||||
#[cfg(all(feature="std", std_integer_atomics))]
|
||||
#[cfg(all(feature = "std", std_integer_atomics))]
|
||||
atomic_impl!(atomic::AtomicIsize, serialize_i64 as i64);
|
||||
|
||||
#[cfg(all(feature="std", std_integer_atomics))]
|
||||
#[cfg(all(feature = "std", std_integer_atomics))]
|
||||
atomic_impl!(atomic::AtomicU8, serialize_u8);
|
||||
|
||||
#[cfg(all(feature="std", std_integer_atomics))]
|
||||
#[cfg(all(feature = "std", std_integer_atomics))]
|
||||
atomic_impl!(atomic::AtomicU16, serialize_u16);
|
||||
|
||||
#[cfg(all(feature="std", std_integer_atomics))]
|
||||
#[cfg(all(feature = "std", std_integer_atomics))]
|
||||
atomic_impl!(atomic::AtomicU32, serialize_u32);
|
||||
|
||||
#[cfg(all(feature="std", std_integer_atomics))]
|
||||
#[cfg(all(feature = "std", std_integer_atomics))]
|
||||
atomic_impl!(atomic::AtomicU64, serialize_u64);
|
||||
|
||||
#[cfg(all(feature="std", std_integer_atomics))]
|
||||
#[cfg(all(feature = "std", std_integer_atomics))]
|
||||
atomic_impl!(atomic::AtomicUsize, serialize_u64 as u64);
|
||||
|
@ -9,8 +9,7 @@ use std::num::Wrapping;
|
||||
use std::ops::Bound;
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::rc::{Rc, Weak as RcWeak};
|
||||
use std::sync::atomic;
|
||||
use std::sync::{Arc, Weak as ArcWeak};
|
||||
use std::sync::{atomic, Arc, Weak as ArcWeak};
|
||||
use std::time::{Duration, UNIX_EPOCH};
|
||||
|
||||
use fnv::FnvHasher;
|
||||
@ -1148,72 +1147,28 @@ macro_rules! assert_de_tokens_atomic {
|
||||
Ok(v) => {
|
||||
let loaded = v.load(atomic::Ordering::SeqCst);
|
||||
assert_eq!($val, loaded);
|
||||
},
|
||||
Err(e) => panic!("tokens failed to deserialize: {}", e)
|
||||
}
|
||||
Err(e) => panic!("tokens failed to deserialize: {}", e),
|
||||
};
|
||||
if de.remaining() > 0 {
|
||||
panic!("{} remaining tokens", de.remaining());
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_atomics() {
|
||||
assert_de_tokens_atomic!(
|
||||
atomic::AtomicBool,
|
||||
true,
|
||||
&[Token::Bool(true)]
|
||||
);
|
||||
assert_de_tokens_atomic!(
|
||||
atomic::AtomicI8,
|
||||
-127,
|
||||
&[Token::I8(-127i8)]
|
||||
);
|
||||
assert_de_tokens_atomic!(
|
||||
atomic::AtomicI16,
|
||||
-510,
|
||||
&[Token::I16(-510i16)]
|
||||
);
|
||||
assert_de_tokens_atomic!(
|
||||
atomic::AtomicI32,
|
||||
-131072,
|
||||
&[Token::I32(-131072i32)]
|
||||
);
|
||||
assert_de_tokens_atomic!(
|
||||
atomic::AtomicI64,
|
||||
-8589934592,
|
||||
&[Token::I64(-8589934592)]
|
||||
);
|
||||
assert_de_tokens_atomic!(
|
||||
atomic::AtomicIsize,
|
||||
-131072isize,
|
||||
&[Token::I32(-131072)]
|
||||
);
|
||||
assert_de_tokens_atomic!(
|
||||
atomic::AtomicU8,
|
||||
127,
|
||||
&[Token::U8(127u8)]
|
||||
);
|
||||
assert_de_tokens_atomic!(
|
||||
atomic::AtomicU16,
|
||||
510u16,
|
||||
&[Token::U16(510u16)]
|
||||
);
|
||||
assert_de_tokens_atomic!(
|
||||
atomic::AtomicU32,
|
||||
131072u32,
|
||||
&[Token::U32(131072u32)]
|
||||
);
|
||||
assert_de_tokens_atomic!(
|
||||
atomic::AtomicU64,
|
||||
8589934592u64,
|
||||
&[Token::U64(8589934592)]
|
||||
);
|
||||
assert_de_tokens_atomic!(
|
||||
atomic::AtomicUsize,
|
||||
131072usize,
|
||||
&[Token::U32(131072)]
|
||||
);
|
||||
assert_de_tokens_atomic!(atomic::AtomicBool, true, &[Token::Bool(true)]);
|
||||
assert_de_tokens_atomic!(atomic::AtomicI8, -127, &[Token::I8(-127i8)]);
|
||||
assert_de_tokens_atomic!(atomic::AtomicI16, -510, &[Token::I16(-510i16)]);
|
||||
assert_de_tokens_atomic!(atomic::AtomicI32, -131072, &[Token::I32(-131072i32)]);
|
||||
assert_de_tokens_atomic!(atomic::AtomicI64, -8589934592, &[Token::I64(-8589934592)]);
|
||||
assert_de_tokens_atomic!(atomic::AtomicIsize, -131072isize, &[Token::I32(-131072)]);
|
||||
assert_de_tokens_atomic!(atomic::AtomicU8, 127, &[Token::U8(127u8)]);
|
||||
assert_de_tokens_atomic!(atomic::AtomicU16, 510u16, &[Token::U16(510u16)]);
|
||||
assert_de_tokens_atomic!(atomic::AtomicU32, 131072u32, &[Token::U32(131072u32)]);
|
||||
assert_de_tokens_atomic!(atomic::AtomicU64, 8589934592u64, &[Token::U64(8589934592)]);
|
||||
assert_de_tokens_atomic!(atomic::AtomicUsize, 131072usize, &[Token::U32(131072)]);
|
||||
}
|
||||
|
||||
declare_error_tests! {
|
||||
|
@ -9,8 +9,7 @@ use std::num::Wrapping;
|
||||
use std::ops::Bound;
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::rc::{Rc, Weak as RcWeak};
|
||||
use std::sync::{Arc, Weak as ArcWeak};
|
||||
use std::sync::atomic;
|
||||
use std::sync::{atomic, Arc, Weak as ArcWeak};
|
||||
use std::time::{Duration, UNIX_EPOCH};
|
||||
|
||||
#[cfg(unix)]
|
||||
|
Loading…
Reference in New Issue
Block a user