2022-05-12 23:33:42 -05:00
|
|
|
#![allow(unused_macro_rules)]
|
|
|
|
|
2022-01-20 21:36:41 -06:00
|
|
|
use serde_test::Token;
|
|
|
|
use std::iter;
|
|
|
|
|
2015-08-27 22:01:09 -05:00
|
|
|
macro_rules! btreeset {
|
|
|
|
() => {
|
|
|
|
BTreeSet::new()
|
|
|
|
};
|
2022-01-20 21:30:34 -06:00
|
|
|
($($value:expr),+) => {{
|
|
|
|
let mut set = BTreeSet::new();
|
|
|
|
$(set.insert($value);)+
|
|
|
|
set
|
|
|
|
}};
|
2015-08-27 22:01:09 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
macro_rules! btreemap {
|
|
|
|
() => {
|
|
|
|
BTreeMap::new()
|
|
|
|
};
|
2022-01-20 21:30:34 -06:00
|
|
|
($($key:expr => $value:expr),+) => {{
|
|
|
|
let mut map = BTreeMap::new();
|
|
|
|
$(map.insert($key, $value);)+
|
|
|
|
map
|
|
|
|
}};
|
2015-08-27 22:01:09 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
macro_rules! hashset {
|
|
|
|
() => {
|
|
|
|
HashSet::new()
|
|
|
|
};
|
2022-01-20 21:30:34 -06:00
|
|
|
($($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
|
|
|
|
}};
|
2015-08-27 22:01:09 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
macro_rules! hashmap {
|
|
|
|
() => {
|
|
|
|
HashMap::new()
|
|
|
|
};
|
2022-01-20 21:30:34 -06:00
|
|
|
($($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
|
|
|
|
}};
|
2015-08-27 22:01:09 -05:00
|
|
|
}
|
2017-09-11 08:54:49 -05:00
|
|
|
|
2022-01-20 21:36:41 -06:00
|
|
|
pub trait SingleTokenIntoIterator {
|
|
|
|
fn into_iter(self) -> iter::Once<Token>;
|
|
|
|
}
|
|
|
|
|
|
|
|
impl SingleTokenIntoIterator for Token {
|
|
|
|
fn into_iter(self) -> iter::Once<Token> {
|
|
|
|
iter::once(self)
|
|
|
|
}
|
2017-09-11 08:54:49 -05:00
|
|
|
}
|
2022-01-20 21:25:06 -06:00
|
|
|
|
2017-09-11 08:54:49 -05:00
|
|
|
macro_rules! seq {
|
2022-01-20 21:36:41 -06:00
|
|
|
($($elem:expr),* $(,)?) => {{
|
|
|
|
use crate::macros::SingleTokenIntoIterator;
|
|
|
|
let mut vec = Vec::new();
|
|
|
|
$(<Vec<Token> as Extend<Token>>::extend(&mut vec, $elem.into_iter());)*
|
|
|
|
vec
|
|
|
|
}};
|
2017-09-11 08:54:49 -05:00
|
|
|
}
|