#[macro_export]
macro_rules! s {
($str:literal) => {
$crate::alloc::string::String::from($str)
};
}
#[macro_export]
macro_rules! bmap {
{} => {
$crate::alloc::collections::BTreeMap::new()
};
{ owned: $($key:expr_2021 => $value:expr_2021),+ $(,)? } => {{
use $crate::alloc::borrow::ToOwned as _;
let mut map = $crate::alloc::collections::BTreeMap::new();
$(map.insert($key.to_owned(), $value.to_owned());)+
map
}};
{ $($key:expr_2021 => $value:expr_2021),+ $(,)? } => {{
let mut map = $crate::alloc::collections::BTreeMap::new();
$(map.insert($key, $value);)+
map
}};
}
#[macro_export]
macro_rules! bset {
{} => {
$crate::alloc::collections::BTreeSet::new()
};
{ owned: $($value:expr_2021),+ $(,)? } => {{
use $crate::alloc::borrow::ToOwned as _;
let mut set = $crate::alloc::collections::BTreeSet::new();
$(set.insert($value.to_owned());)+
set
}};
{ $($value:expr_2021),+ $(,)? } => {{
let mut set = $crate::alloc::collections::BTreeSet::new();
$(set.insert($value);)+
set
}};
}
#[macro_export]
macro_rules! list {
{} => {
$crate::alloc::collections::LinkedList::new()
};
{ owned: $($value:expr_2021)=>+ } => {{
use $crate::alloc::borrow::ToOwned as _;
let mut list = $crate::alloc::collections::LinkedList::new();
$(list.push_back($value.to_owned());)+
list
}};
{ $($value:expr_2021)=>+ } => {{
let mut list = $crate::alloc::collections::LinkedList::new();
$(list.push_back($value);)+
list
}};
}
#[macro_export]
macro_rules! deque {
{} => {
$crate::alloc::collections::VecDeque::new()
};
{ owned: $($value:expr_2021)=>+ } => {{
use $crate::alloc::borrow::ToOwned as _;
let mut deque = $crate::alloc::collections::VecDeque::with_capacity(
const { <[()]>::len(&[$({ ::core::stringify!($value); }),+]) },
);
$(deque.push_back($value.to_owned());)+
deque
}};
{ $($value:expr_2021)=>+ } => {{
let mut deque = $crate::alloc::collections::VecDeque::with_capacity(
const { <[()]>::len(&[$({ ::core::stringify!($value); }),+]) },
);
$(deque.push_back($value);)+
deque
}};
}
#[macro_export]
macro_rules! heap {
{} => {
$crate::alloc::collections::BinaryHeap::new()
};
{ owned: $($value:expr_2021),+ $(,)? } => {{
use $crate::alloc::borrow::ToOwned as _;
let mut heap = $crate::alloc::collections::BinaryHeap::with_capacity(
const { <[()]>::len(&[$({ ::core::stringify!($value); }),+]) },
);
$(heap.push($value.to_owned());)+
heap
}};
{ $($value:expr_2021),+ $(,)? } => {{
let mut heap = $crate::alloc::collections::BinaryHeap::with_capacity(
const { <[()]>::len(&[$({ ::core::stringify!($value); }),+]) },
);
$(heap.push($value);)+
heap
}};
}
#[cfg(feature = "std")]
#[macro_export]
macro_rules! map {
{} => {
$crate::std::collections::HashMap::new()
};
{ owned: $($key:expr_2021 => $value:expr_2021),+ $(,)? } => {{
use $crate::alloc::borrow::ToOwned as _;
let mut map = $crate::std::collections::HashMap::with_capacity(
const { <[()]>::len(&[$({ ::core::stringify!($key); }),+]) },
);
$(map.insert($key.to_owned(), $value.to_owned());)+
map
}};
{ $($key:expr_2021 => $value:expr_2021),+ $(,)? } => {{
let mut map = $crate::std::collections::HashMap::with_capacity(
const { <[()]>::len(&[$({ ::core::stringify!($key); }),+]) },
);
$(map.insert($key, $value);)+
map
}};
}
#[cfg(feature = "std")]
#[macro_export]
macro_rules! set {
{} => {
$crate::std::collections::HashSet::new()
};
{ owned: $($value:expr_2021),+ $(,)? } => {{
use $crate::alloc::borrow::ToOwned as _;
let mut set = $crate::std::collections::HashSet::with_capacity(
const { <[()]>::len(&[$({ ::core::stringify!($value); }),+]) },
);
$(set.insert($value.to_owned());)+
set
}};
{ $($value:expr_2021),+ $(,)? } => {{
let mut set = $crate::std::collections::HashSet::with_capacity(
const { <[()]>::len(&[$({ ::core::stringify!($value); }),+]) },
);
$(set.insert($value);)+
set
}};
}