Skip to content

Instantly share code, notes, and snippets.

@sfackler
Created January 1, 2014 23:07
Show Gist options
  • Save sfackler/4c4e93f896e881fae811 to your computer and use it in GitHub Desktop.
Save sfackler/4c4e93f896e881fae811 to your computer and use it in GitHub Desktop.
macro_rules! range(
($low:expr, $high:expr, "()") => (
Range::new(Some(RangeBound::new($low, Exclusive)),
Some(RangeBound::new($high, Exclusive)))
);
($low:expr, $high:expr, "[]") => (
Range::new(Some(RangeBound::new($low, Inclusive)),
Some(RangeBound::new($high, Inclusive)))
);
($low:expr, $high:expr, "(]") => (
Range::new(Some(RangeBound::new($low, Exclusive)),
Some(RangeBound::new($high, Inclusive)))
)
($low:expr, $high:expr, "[)") => (
Range::new(Some(RangeBound::new($low, Inclusive)),
Some(RangeBound::new($high, Exclusive)))
);
($low: expr, $high:expr) => (
range!($low, $high, "[)")
);
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment