Clean up test suite's macro formatting

This commit is contained in:
David Tolnay 2022-01-20 19:30:34 -08:00
parent 80d01a3a79
commit 157dc44c51
No known key found for this signature in database
GPG Key ID: F9BA143B95FF6D82

View File

@ -2,68 +2,56 @@ macro_rules! btreeset {
() => { () => {
BTreeSet::new() BTreeSet::new()
}; };
($($value:expr),+) => { ($($value:expr),+) => {{
{ let mut set = BTreeSet::new();
let mut set = BTreeSet::new(); $(set.insert($value);)+
$(set.insert($value);)+ set
set }};
}
}
} }
macro_rules! btreemap { macro_rules! btreemap {
() => { () => {
BTreeMap::new() BTreeMap::new()
}; };
($($key:expr => $value:expr),+) => { ($($key:expr => $value:expr),+) => {{
{ let mut map = BTreeMap::new();
let mut map = BTreeMap::new(); $(map.insert($key, $value);)+
$(map.insert($key, $value);)+ map
map }};
}
}
} }
macro_rules! hashset { macro_rules! hashset {
() => { () => {
HashSet::new() HashSet::new()
}; };
($($value:expr),+) => { ($($value:expr),+) => {{
{ let mut set = HashSet::new();
let mut set = HashSet::new(); $(set.insert($value);)+
$(set.insert($value);)+ set
set }};
} ($hasher:ident @ $($value:expr),+) => {{
}; use std::hash::BuildHasherDefault;
($hasher:ident @ $($value:expr),+) => { let mut set = HashSet::with_hasher(BuildHasherDefault::<$hasher>::default());
{ $(set.insert($value);)+
use std::hash::BuildHasherDefault; set
let mut set = HashSet::with_hasher(BuildHasherDefault::<$hasher>::default()); }};
$(set.insert($value);)+
set
}
}
} }
macro_rules! hashmap { macro_rules! hashmap {
() => { () => {
HashMap::new() HashMap::new()
}; };
($($key:expr => $value:expr),+) => { ($($key:expr => $value:expr),+) => {{
{ let mut map = HashMap::new();
let mut map = HashMap::new(); $(map.insert($key, $value);)+
$(map.insert($key, $value);)+ map
map }};
} ($hasher:ident @ $($key:expr => $value:expr),+) => {{
}; use std::hash::BuildHasherDefault;
($hasher:ident @ $($key:expr => $value:expr),+) => { let mut map = HashMap::with_hasher(BuildHasherDefault::<$hasher>::default());
{ $(map.insert($key, $value);)+
use std::hash::BuildHasherDefault; map
let mut map = HashMap::with_hasher(BuildHasherDefault::<$hasher>::default()); }};
$(map.insert($key, $value);)+
map
}
}
} }
macro_rules! seq_impl { macro_rules! seq_impl {
@ -78,7 +66,7 @@ macro_rules! seq_impl {
}; };
($first:expr, $($elem:tt)*) => { ($first:expr, $($elem:tt)*) => {
Some($first).into_iter().chain(seq!($($elem)*)) Some($first).into_iter().chain(seq!($($elem)*))
} };
} }
macro_rules! seq { macro_rules! seq {