Restructure range! internals a bit
This commit is contained in:
parent
bb6fbfbc6f
commit
dfde45e7c7
@ -9,11 +9,6 @@ use time::Timespec;
|
|||||||
/// The `quote!` macro can make it easier to create ranges. It roughly mirrors
|
/// The `quote!` macro can make it easier to create ranges. It roughly mirrors
|
||||||
/// traditional mathematic range syntax.
|
/// traditional mathematic range syntax.
|
||||||
///
|
///
|
||||||
/// # Note
|
|
||||||
///
|
|
||||||
/// The `Range`, `RangeBound`, `Inclusive`, and `Exclusive` types must be
|
|
||||||
/// directly usable at the location the macro is used.
|
|
||||||
///
|
|
||||||
/// # Example
|
/// # Example
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
@ -22,10 +17,10 @@ use time::Timespec;
|
|||||||
/// #[phase(syntax, link)]
|
/// #[phase(syntax, link)]
|
||||||
/// extern crate postgres;
|
/// extern crate postgres;
|
||||||
///
|
///
|
||||||
/// use postgres::types::range::{Range, RangeBound, Inclusive, Exclusive};
|
/// use postgres::types::range::Range;
|
||||||
///
|
///
|
||||||
/// fn main() {
|
/// fn main() {
|
||||||
/// # let mut r: Range<i32>;
|
/// let mut r: Range<i32>;
|
||||||
/// // a closed interval
|
/// // a closed interval
|
||||||
/// r = range!('[' 5i32, 10i32 ']');
|
/// r = range!('[' 5i32, 10i32 ']');
|
||||||
/// // an open interval
|
/// // an open interval
|
||||||
@ -48,35 +43,55 @@ use time::Timespec;
|
|||||||
/// }
|
/// }
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
macro_rules! range(
|
macro_rules! range(
|
||||||
(empty) => (Range::empty());
|
(empty) => (::postgres::types::range::Range::empty());
|
||||||
('(', ')') => (Range::new(None, None));
|
('(', ')') => (::postgres::types::range::Range::new(None, None));
|
||||||
('(', $h:expr ')') => (
|
('(', $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 ']') => (
|
('(', $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, ')') => (
|
('(' $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, ')') => (
|
('[' $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 ')') => (
|
('(' $l:expr, $h:expr ')') => (
|
||||||
Range::new(Some(RangeBound::new($l, Exclusive)),
|
::postgres::types::range::Range::new(
|
||||||
Some(RangeBound::new($h, Exclusive)))
|
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 ']') => (
|
('(' $l:expr, $h:expr ']') => (
|
||||||
Range::new(Some(RangeBound::new($l, Exclusive)),
|
::postgres::types::range::Range::new(
|
||||||
Some(RangeBound::new($h, Inclusive)))
|
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 ')') => (
|
('[' $l:expr, $h:expr ')') => (
|
||||||
Range::new(Some(RangeBound::new($l, Inclusive)),
|
::postgres::types::range::Range::new(
|
||||||
Some(RangeBound::new($h, Exclusive)))
|
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 ']') => (
|
('[' $l:expr, $h:expr ']') => (
|
||||||
Range::new(Some(RangeBound::new($l, Inclusive)),
|
::postgres::types::range::Range::new(
|
||||||
Some(RangeBound::new($h, Inclusive)))
|
Some(::postgres::types::range::RangeBound::new($l,
|
||||||
|
::postgres::types::range::Inclusive)),
|
||||||
|
Some(::postgres::types::range::RangeBound::new($h,
|
||||||
|
::postgres::types::range::Inclusive)))
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user