aboutsummaryrefslogtreecommitdiff
path: root/helix-core/src/macros.rs
diff options
context:
space:
mode:
authorBlaž Hrastnik2020-09-21 09:24:16 +0000
committerBlaž Hrastnik2020-09-21 09:24:16 +0000
commit935cfeae576f734e6cbd455bfa39df014700ae86 (patch)
treea4abe959b718f265ade4a66a844bfefadc546f90 /helix-core/src/macros.rs
parent48330ddb5f36a1c5f44a636525089a019ce4439d (diff)
Split parts of helix-term into helix-view.
It still largely depends on term for some types but I plan to change that later.
Diffstat (limited to 'helix-core/src/macros.rs')
-rw-r--r--helix-core/src/macros.rs17
1 files changed, 17 insertions, 0 deletions
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
+ }
+ };
+}