mirror of https://github.com/helix-editor/helix
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
18 lines
523 B
Rust
18 lines
523 B
Rust
4 years ago
|
#[macro_export]
|
||
4 years ago
|
macro_rules! hashmap {
|
||
|
(@single $($x:tt)*) => (());
|
||
|
(@count $($rest:expr),*) => (<[()]>::len(&[$(hashmap!(@single $rest)),*]));
|
||
|
|
||
|
($($key:expr => $value:expr,)+) => { hashmap!($($key => $value),+) };
|
||
|
($($key:expr => $value:expr),*) => {
|
||
|
{
|
||
|
let _cap = hashmap!(@count $($key),*);
|
||
|
let mut _map = ::std::collections::HashMap::with_capacity(_cap);
|
||
|
$(
|
||
|
let _ = _map.insert($key, $value);
|
||
|
)*
|
||
|
_map
|
||
|
}
|
||
|
};
|
||
|
}
|