Skip to content
This repository has been archived by the owner on Nov 6, 2020. It is now read-only.

Commit

Permalink
Merge pull request #44 from gavofyork/gav
Browse files Browse the repository at this point in the history
Nice macros.
  • Loading branch information
debris committed Jan 13, 2016
2 parents 8be95e5 + b23ec6e commit 8a78953
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions src/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,31 @@ pub use uint::*;
pub use bytes::*;
pub use vector::*;
pub use sha3::*;

#[macro_export]
macro_rules! map {
( $( $x:expr => $y:expr ),* ) => {
vec![ $( ($x, $y) ),* ].into_iter().collect::<BTreeMap<_, _>>()
}
}

#[macro_export]
macro_rules! mapx {
( $( $x:expr => $y:expr ),* ) => {
vec![ $( ( From::from($x), From::from($y) ) ),* ].into_iter().collect::<BTreeMap<_, _>>()
}
}

#[macro_export]
macro_rules! x {
( $x:expr ) => {
From::from($x)
}
}

#[macro_export]
macro_rules! xx {
( $x:expr ) => {
From::from(From::from($x))
}
}

0 comments on commit 8a78953

Please sign in to comment.