aboutsummaryrefslogtreecommitdiff
path: root/src/util.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/util.rs')
-rw-r--r--src/util.rs19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/util.rs b/src/util.rs
index eeeda4e..6051a96 100644
--- a/src/util.rs
+++ b/src/util.rs
@@ -38,3 +38,22 @@ pub fn insert_bytes(pos: usize, buf: &mut Vec<u8>, input: &mut [u8]) {
buf.insert(pos, *i)
}
}
+
+#[macro_export]
+macro_rules! map {
+ // map-like
+ ($($k:expr => $v:expr),* $(,)?) => {
+ std::iter::Iterator::collect(std::array::IntoIter::new([$(($k, $v),)*]))
+ };
+ // set-like
+ ($($v:expr),* $(,)?) => {
+ std::iter::Iterator::collect(std::array::IntoIter::new([$($v,)*]))
+ };
+}
+
+#[macro_export]
+macro_rules! s {
+ ($values:expr) => {
+ std::string::String::from($values)
+ };
+}