aboutsummaryrefslogtreecommitdiff
path: root/helix-term/src/macros.rs
diff options
context:
space:
mode:
authorBlaž Hrastnik2020-09-10 04:55:18 +0000
committerBlaž Hrastnik2020-09-10 09:19:59 +0000
commitb647c7a773fb3323ccc884f4d0d4ce25c3e8aea8 (patch)
tree3ad4ef86e92c2482b3dcf14aaca4bfb74038678e /helix-term/src/macros.rs
parent25b3f98e3d200ae7f0f08b10be50552359502494 (diff)
tree-sitter based syntax highlighting draft
Diffstat (limited to 'helix-term/src/macros.rs')
-rw-r--r--helix-term/src/macros.rs16
1 files changed, 16 insertions, 0 deletions
diff --git a/helix-term/src/macros.rs b/helix-term/src/macros.rs
new file mode 100644
index 00000000..3b22a786
--- /dev/null
+++ b/helix-term/src/macros.rs
@@ -0,0 +1,16 @@
+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
+ }
+ };
+}