From 935cfeae576f734e6cbd455bfa39df014700ae86 Mon Sep 17 00:00:00 2001 From: Blaž Hrastnik Date: Mon, 21 Sep 2020 18:24:16 +0900 Subject: Split parts of helix-term into helix-view. It still largely depends on term for some types but I plan to change that later. --- helix-core/src/macros.rs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 helix-core/src/macros.rs (limited to 'helix-core/src/macros.rs') diff --git a/helix-core/src/macros.rs b/helix-core/src/macros.rs new file mode 100644 index 00000000..1321ea5f --- /dev/null +++ b/helix-core/src/macros.rs @@ -0,0 +1,17 @@ +#[macro_export] +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 + } + }; +} -- cgit v1.2.3-70-g09d2