From 157dc44c51b499bec82722994b5876f7f56d5511 Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Thu, 20 Jan 2022 19:30:34 -0800 Subject: [PATCH] Clean up test suite's macro formatting --- test_suite/tests/macros/mod.rs | 78 ++++++++++++++-------------------- 1 file changed, 33 insertions(+), 45 deletions(-) diff --git a/test_suite/tests/macros/mod.rs b/test_suite/tests/macros/mod.rs index 3c61e41a..d1067329 100644 --- a/test_suite/tests/macros/mod.rs +++ b/test_suite/tests/macros/mod.rs @@ -2,68 +2,56 @@ macro_rules! btreeset { () => { BTreeSet::new() }; - ($($value:expr),+) => { - { - let mut set = BTreeSet::new(); - $(set.insert($value);)+ - set - } - } + ($($value:expr),+) => {{ + let mut set = BTreeSet::new(); + $(set.insert($value);)+ + set + }}; } macro_rules! btreemap { () => { BTreeMap::new() }; - ($($key:expr => $value:expr),+) => { - { - let mut map = BTreeMap::new(); - $(map.insert($key, $value);)+ - map - } - } + ($($key:expr => $value:expr),+) => {{ + let mut map = BTreeMap::new(); + $(map.insert($key, $value);)+ + map + }}; } macro_rules! hashset { () => { HashSet::new() }; - ($($value:expr),+) => { - { - let mut set = HashSet::new(); - $(set.insert($value);)+ - set - } - }; - ($hasher:ident @ $($value:expr),+) => { - { - use std::hash::BuildHasherDefault; - let mut set = HashSet::with_hasher(BuildHasherDefault::<$hasher>::default()); - $(set.insert($value);)+ - set - } - } + ($($value:expr),+) => {{ + let mut set = HashSet::new(); + $(set.insert($value);)+ + set + }}; + ($hasher:ident @ $($value:expr),+) => {{ + use std::hash::BuildHasherDefault; + let mut set = HashSet::with_hasher(BuildHasherDefault::<$hasher>::default()); + $(set.insert($value);)+ + set + }}; } macro_rules! hashmap { () => { HashMap::new() }; - ($($key:expr => $value:expr),+) => { - { - let mut map = HashMap::new(); - $(map.insert($key, $value);)+ - map - } - }; - ($hasher:ident @ $($key:expr => $value:expr),+) => { - { - use std::hash::BuildHasherDefault; - let mut map = HashMap::with_hasher(BuildHasherDefault::<$hasher>::default()); - $(map.insert($key, $value);)+ - map - } - } + ($($key:expr => $value:expr),+) => {{ + let mut map = HashMap::new(); + $(map.insert($key, $value);)+ + map + }}; + ($hasher:ident @ $($key:expr => $value:expr),+) => {{ + use std::hash::BuildHasherDefault; + let mut map = HashMap::with_hasher(BuildHasherDefault::<$hasher>::default()); + $(map.insert($key, $value);)+ + map + }}; } macro_rules! seq_impl { @@ -78,7 +66,7 @@ macro_rules! seq_impl { }; ($first:expr, $($elem:tt)*) => { Some($first).into_iter().chain(seq!($($elem)*)) - } + }; } macro_rules! seq {