From dfde45e7c7f94cd5d41bd69bb2fbee8d9843c3b0 Mon Sep 17 00:00:00 2001 From: Steven Fackler Date: Sat, 26 Jul 2014 00:12:25 -0700 Subject: [PATCH] Restructure range! internals a bit --- src/lib/types/range.rs | 57 ++++++++++++++++++++++++++---------------- 1 file changed, 36 insertions(+), 21 deletions(-) diff --git a/src/lib/types/range.rs b/src/lib/types/range.rs index 4fd7e11d..24f0a754 100644 --- a/src/lib/types/range.rs +++ b/src/lib/types/range.rs @@ -9,11 +9,6 @@ use time::Timespec; /// The `quote!` macro can make it easier to create ranges. It roughly mirrors /// traditional mathematic range syntax. /// -/// # Note -/// -/// The `Range`, `RangeBound`, `Inclusive`, and `Exclusive` types must be -/// directly usable at the location the macro is used. -/// /// # Example /// /// ```rust @@ -22,10 +17,10 @@ use time::Timespec; /// #[phase(syntax, link)] /// extern crate postgres; /// -/// use postgres::types::range::{Range, RangeBound, Inclusive, Exclusive}; +/// use postgres::types::range::Range; /// /// fn main() { -/// # let mut r: Range; +/// let mut r: Range; /// // a closed interval /// r = range!('[' 5i32, 10i32 ']'); /// // an open interval @@ -48,35 +43,55 @@ use time::Timespec; /// } #[macro_export] macro_rules! range( - (empty) => (Range::empty()); - ('(', ')') => (Range::new(None, None)); + (empty) => (::postgres::types::range::Range::empty()); + ('(', ')') => (::postgres::types::range::Range::new(None, None)); ('(', $h:expr ')') => ( - Range::new(None, Some(RangeBound::new($h, Exclusive))) + ::postgres::types::range::Range::new(None, + Some(::postgres::types::range::RangeBound::new($h, + ::postgres::types::range::Exclusive))) ); ('(', $h:expr ']') => ( - Range::new(None, Some(RangeBound::new($h, Inclusive))) + ::postgres::types::range::Range::new(None, + Some(::postgres::types::range::RangeBound::new($h, + ::postgres::types::range::Inclusive))) ); ('(' $l:expr, ')') => ( - Range::new(Some(RangeBound::new($l, Exclusive)), None) + ::postgres::types::range::Range::new( + Some(::postgres::types::range::RangeBound::new($l, + ::postgres::types::range::Exclusive)), None) ); ('[' $l:expr, ')') => ( - Range::new(Some(RangeBound::new($l, Inclusive)), None) + ::postgres::types::range::Range::new( + Some(::postgres::types::range::RangeBound::new($l, + ::postgres::types::range::Inclusive)), None) ); ('(' $l:expr, $h:expr ')') => ( - Range::new(Some(RangeBound::new($l, Exclusive)), - Some(RangeBound::new($h, Exclusive))) + ::postgres::types::range::Range::new( + Some(::postgres::types::range::RangeBound::new($l, + ::postgres::types::range::Exclusive)), + Some(::postgres::types::range::RangeBound::new($h, + ::postgres::types::range::Exclusive))) ); ('(' $l:expr, $h:expr ']') => ( - Range::new(Some(RangeBound::new($l, Exclusive)), - Some(RangeBound::new($h, Inclusive))) + ::postgres::types::range::Range::new( + Some(::postgres::types::range::RangeBound::new($l, + ::postgres::types::range::Exclusive)), + Some(::postgres::types::range::RangeBound::new($h, + ::postgres::types::range::Inclusive))) ); ('[' $l:expr, $h:expr ')') => ( - Range::new(Some(RangeBound::new($l, Inclusive)), - Some(RangeBound::new($h, Exclusive))) + ::postgres::types::range::Range::new( + Some(::postgres::types::range::RangeBound::new($l, + ::postgres::types::range::Inclusive)), + Some(::postgres::types::range::RangeBound::new($h, + ::postgres::types::range::Exclusive))) ); ('[' $l:expr, $h:expr ']') => ( - Range::new(Some(RangeBound::new($l, Inclusive)), - Some(RangeBound::new($h, Inclusive))) + ::postgres::types::range::Range::new( + Some(::postgres::types::range::RangeBound::new($l, + ::postgres::types::range::Inclusive)), + Some(::postgres::types::range::RangeBound::new($h, + ::postgres::types::range::Inclusive))) ) )