Skip to content

Commit dfde45e

Browse files
committed
Restructure range! internals a bit
1 parent bb6fbfb commit dfde45e

1 file changed

Lines changed: 36 additions & 21 deletions

File tree

src/lib/types/range.rs

Lines changed: 36 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,6 @@ use time::Timespec;
99
/// The `quote!` macro can make it easier to create ranges. It roughly mirrors
1010
/// traditional mathematic range syntax.
1111
///
12-
/// # Note
13-
///
14-
/// The `Range`, `RangeBound`, `Inclusive`, and `Exclusive` types must be
15-
/// directly usable at the location the macro is used.
16-
///
1712
/// # Example
1813
///
1914
/// ```rust
@@ -22,10 +17,10 @@ use time::Timespec;
2217
/// #[phase(syntax, link)]
2318
/// extern crate postgres;
2419
///
25-
/// use postgres::types::range::{Range, RangeBound, Inclusive, Exclusive};
20+
/// use postgres::types::range::Range;
2621
///
2722
/// fn main() {
28-
/// # let mut r: Range<i32>;
23+
/// let mut r: Range<i32>;
2924
/// // a closed interval
3025
/// r = range!('[' 5i32, 10i32 ']');
3126
/// // an open interval
@@ -48,35 +43,55 @@ use time::Timespec;
4843
/// }
4944
#[macro_export]
5045
macro_rules! range(
51-
(empty) => (Range::empty());
52-
('(', ')') => (Range::new(None, None));
46+
(empty) => (::postgres::types::range::Range::empty());
47+
('(', ')') => (::postgres::types::range::Range::new(None, None));
5348
('(', $h:expr ')') => (
54-
Range::new(None, Some(RangeBound::new($h, Exclusive)))
49+
::postgres::types::range::Range::new(None,
50+
Some(::postgres::types::range::RangeBound::new($h,
51+
::postgres::types::range::Exclusive)))
5552
);
5653
('(', $h:expr ']') => (
57-
Range::new(None, Some(RangeBound::new($h, Inclusive)))
54+
::postgres::types::range::Range::new(None,
55+
Some(::postgres::types::range::RangeBound::new($h,
56+
::postgres::types::range::Inclusive)))
5857
);
5958
('(' $l:expr, ')') => (
60-
Range::new(Some(RangeBound::new($l, Exclusive)), None)
59+
::postgres::types::range::Range::new(
60+
Some(::postgres::types::range::RangeBound::new($l,
61+
::postgres::types::range::Exclusive)), None)
6162
);
6263
('[' $l:expr, ')') => (
63-
Range::new(Some(RangeBound::new($l, Inclusive)), None)
64+
::postgres::types::range::Range::new(
65+
Some(::postgres::types::range::RangeBound::new($l,
66+
::postgres::types::range::Inclusive)), None)
6467
);
6568
('(' $l:expr, $h:expr ')') => (
66-
Range::new(Some(RangeBound::new($l, Exclusive)),
67-
Some(RangeBound::new($h, Exclusive)))
69+
::postgres::types::range::Range::new(
70+
Some(::postgres::types::range::RangeBound::new($l,
71+
::postgres::types::range::Exclusive)),
72+
Some(::postgres::types::range::RangeBound::new($h,
73+
::postgres::types::range::Exclusive)))
6874
);
6975
('(' $l:expr, $h:expr ']') => (
70-
Range::new(Some(RangeBound::new($l, Exclusive)),
71-
Some(RangeBound::new($h, Inclusive)))
76+
::postgres::types::range::Range::new(
77+
Some(::postgres::types::range::RangeBound::new($l,
78+
::postgres::types::range::Exclusive)),
79+
Some(::postgres::types::range::RangeBound::new($h,
80+
::postgres::types::range::Inclusive)))
7281
);
7382
('[' $l:expr, $h:expr ')') => (
74-
Range::new(Some(RangeBound::new($l, Inclusive)),
75-
Some(RangeBound::new($h, Exclusive)))
83+
::postgres::types::range::Range::new(
84+
Some(::postgres::types::range::RangeBound::new($l,
85+
::postgres::types::range::Inclusive)),
86+
Some(::postgres::types::range::RangeBound::new($h,
87+
::postgres::types::range::Exclusive)))
7688
);
7789
('[' $l:expr, $h:expr ']') => (
78-
Range::new(Some(RangeBound::new($l, Inclusive)),
79-
Some(RangeBound::new($h, Inclusive)))
90+
::postgres::types::range::Range::new(
91+
Some(::postgres::types::range::RangeBound::new($l,
92+
::postgres::types::range::Inclusive)),
93+
Some(::postgres::types::range::RangeBound::new($h,
94+
::postgres::types::range::Inclusive)))
8095
)
8196
)
8297

0 commit comments

Comments
 (0)