17e2e9c0cSopenharmony_ci#![allow(unused_macro_rules)] 27e2e9c0cSopenharmony_ci 37e2e9c0cSopenharmony_ciuse serde_test::Token; 47e2e9c0cSopenharmony_ciuse std::iter; 57e2e9c0cSopenharmony_ci 67e2e9c0cSopenharmony_cimacro_rules! btreeset { 77e2e9c0cSopenharmony_ci () => { 87e2e9c0cSopenharmony_ci BTreeSet::new() 97e2e9c0cSopenharmony_ci }; 107e2e9c0cSopenharmony_ci ($($value:expr),+) => {{ 117e2e9c0cSopenharmony_ci let mut set = BTreeSet::new(); 127e2e9c0cSopenharmony_ci $(set.insert($value);)+ 137e2e9c0cSopenharmony_ci set 147e2e9c0cSopenharmony_ci }}; 157e2e9c0cSopenharmony_ci} 167e2e9c0cSopenharmony_ci 177e2e9c0cSopenharmony_cimacro_rules! btreemap { 187e2e9c0cSopenharmony_ci () => { 197e2e9c0cSopenharmony_ci BTreeMap::new() 207e2e9c0cSopenharmony_ci }; 217e2e9c0cSopenharmony_ci ($($key:expr => $value:expr),+) => {{ 227e2e9c0cSopenharmony_ci let mut map = BTreeMap::new(); 237e2e9c0cSopenharmony_ci $(map.insert($key, $value);)+ 247e2e9c0cSopenharmony_ci map 257e2e9c0cSopenharmony_ci }}; 267e2e9c0cSopenharmony_ci} 277e2e9c0cSopenharmony_ci 287e2e9c0cSopenharmony_cimacro_rules! hashset { 297e2e9c0cSopenharmony_ci () => { 307e2e9c0cSopenharmony_ci HashSet::new() 317e2e9c0cSopenharmony_ci }; 327e2e9c0cSopenharmony_ci ($($value:expr),+) => {{ 337e2e9c0cSopenharmony_ci let mut set = HashSet::new(); 347e2e9c0cSopenharmony_ci $(set.insert($value);)+ 357e2e9c0cSopenharmony_ci set 367e2e9c0cSopenharmony_ci }}; 377e2e9c0cSopenharmony_ci ($hasher:ident @ $($value:expr),+) => {{ 387e2e9c0cSopenharmony_ci use std::hash::BuildHasherDefault; 397e2e9c0cSopenharmony_ci let mut set = HashSet::with_hasher(BuildHasherDefault::<$hasher>::default()); 407e2e9c0cSopenharmony_ci $(set.insert($value);)+ 417e2e9c0cSopenharmony_ci set 427e2e9c0cSopenharmony_ci }}; 437e2e9c0cSopenharmony_ci} 447e2e9c0cSopenharmony_ci 457e2e9c0cSopenharmony_cimacro_rules! hashmap { 467e2e9c0cSopenharmony_ci () => { 477e2e9c0cSopenharmony_ci HashMap::new() 487e2e9c0cSopenharmony_ci }; 497e2e9c0cSopenharmony_ci ($($key:expr => $value:expr),+) => {{ 507e2e9c0cSopenharmony_ci let mut map = HashMap::new(); 517e2e9c0cSopenharmony_ci $(map.insert($key, $value);)+ 527e2e9c0cSopenharmony_ci map 537e2e9c0cSopenharmony_ci }}; 547e2e9c0cSopenharmony_ci ($hasher:ident @ $($key:expr => $value:expr),+) => {{ 557e2e9c0cSopenharmony_ci use std::hash::BuildHasherDefault; 567e2e9c0cSopenharmony_ci let mut map = HashMap::with_hasher(BuildHasherDefault::<$hasher>::default()); 577e2e9c0cSopenharmony_ci $(map.insert($key, $value);)+ 587e2e9c0cSopenharmony_ci map 597e2e9c0cSopenharmony_ci }}; 607e2e9c0cSopenharmony_ci} 617e2e9c0cSopenharmony_ci 627e2e9c0cSopenharmony_cipub trait SingleTokenIntoIterator { 637e2e9c0cSopenharmony_ci fn into_iter(self) -> iter::Once<Token>; 647e2e9c0cSopenharmony_ci} 657e2e9c0cSopenharmony_ci 667e2e9c0cSopenharmony_ciimpl SingleTokenIntoIterator for Token { 677e2e9c0cSopenharmony_ci fn into_iter(self) -> iter::Once<Token> { 687e2e9c0cSopenharmony_ci iter::once(self) 697e2e9c0cSopenharmony_ci } 707e2e9c0cSopenharmony_ci} 717e2e9c0cSopenharmony_ci 727e2e9c0cSopenharmony_cimacro_rules! seq { 737e2e9c0cSopenharmony_ci ($($elem:expr),* $(,)?) => {{ 747e2e9c0cSopenharmony_ci use crate::macros::SingleTokenIntoIterator; 757e2e9c0cSopenharmony_ci let mut vec = Vec::new(); 767e2e9c0cSopenharmony_ci $(<Vec<Token> as Extend<Token>>::extend(&mut vec, $elem.into_iter());)* 777e2e9c0cSopenharmony_ci vec 787e2e9c0cSopenharmony_ci }}; 797e2e9c0cSopenharmony_ci} 80