11//! Types dealing with ranges of values
22#![ doc( html_root_url="https://sfackler.github.io/doc" ) ]
3- #![ feature( io, core) ]
3+ #![ cfg_attr( test, feature( core) ) ]
4+ #![ feature( io) ]
45
56extern crate postgres;
67extern crate time;
@@ -127,7 +128,7 @@ macro_rules! bounded_normalizable {
127128 ( $t: ident) => (
128129 impl Normalizable for $t {
129130 fn normalize<S >( bound: RangeBound <S , $t>) -> RangeBound <S , $t> where S : BoundSided {
130- match ( BoundSided :: side( None :: < S > ) , bound. type_) {
131+ match ( < S as BoundSided > :: side( ) , bound. type_) {
131132 ( Upper , Inclusive ) => {
132133 assert!( bound. value != $t:: MAX ) ;
133134 RangeBound :: new( bound. value + 1 , Exclusive )
@@ -166,7 +167,7 @@ pub enum BoundSide {
166167pub trait BoundSided {
167168 /// Returns the bound side this type corresponds to
168169 // param is a hack to get around lack of hints for self type
169- fn side ( _ : Option < Self > ) -> BoundSide ;
170+ fn side ( ) -> BoundSide ;
170171}
171172
172173/// A tag type representing an upper bound
@@ -178,13 +179,13 @@ pub enum UpperBound {}
178179pub enum LowerBound { }
179180
180181impl BoundSided for UpperBound {
181- fn side ( _ : Option < UpperBound > ) -> BoundSide {
182+ fn side ( ) -> BoundSide {
182183 Upper
183184 }
184185}
185186
186187impl BoundSided for LowerBound {
187- fn side ( _ : Option < LowerBound > ) -> BoundSide {
188+ fn side ( ) -> BoundSide {
188189 Lower
189190 }
190191}
@@ -226,7 +227,7 @@ impl<S, T> fmt::Debug for RangeBound<S, T> where S: BoundSided, T: fmt::Debug {
226227 Exclusive => ( '(' , ')' ) ,
227228 } ;
228229
229- match BoundSided :: side ( None :: < S > ) {
230+ match < S as BoundSided > :: side ( ) {
230231 Lower => write ! ( fmt, "{}{:?}" , lower, self . value) ,
231232 Upper => write ! ( fmt, "{:?}{}" , self . value, upper) ,
232233 }
@@ -247,7 +248,7 @@ impl<S, T> Eq for RangeBound<S, T> where S: BoundSided, T: Eq {}
247248
248249impl < S , T > PartialOrd for RangeBound < S , T > where S : BoundSided , T : PartialOrd {
249250 fn partial_cmp ( & self , other : & RangeBound < S , T > ) -> Option < Ordering > {
250- match ( BoundSided :: side ( None :: < S > ) , self . type_ , other. type_ ,
251+ match ( < S as BoundSided > :: side ( ) , self . type_ , other. type_ ,
251252 self . value . partial_cmp ( & other. value ) ) {
252253 ( Upper , Exclusive , Inclusive , Some ( Ordering :: Equal ) )
253254 | ( Lower , Inclusive , Exclusive , Some ( Ordering :: Equal ) ) => Some ( Ordering :: Less ) ,
@@ -260,7 +261,7 @@ impl<S, T> PartialOrd for RangeBound<S, T> where S: BoundSided, T: PartialOrd {
260261
261262impl < S , T > Ord for RangeBound < S , T > where S : BoundSided , T : Ord {
262263 fn cmp ( & self , other : & RangeBound < S , T > ) -> Ordering {
263- match ( BoundSided :: side ( None :: < S > ) , self . type_ , other. type_ ,
264+ match ( < S as BoundSided > :: side ( ) , self . type_ , other. type_ ,
264265 self . value . cmp ( & other. value ) ) {
265266 ( Upper , Exclusive , Inclusive , Ordering :: Equal )
266267 | ( Lower , Inclusive , Exclusive , Ordering :: Equal ) => Ordering :: Less ,
@@ -279,7 +280,7 @@ impl<S, T> RangeBound<S, T> where S: BoundSided, T: PartialOrd {
279280
280281 /// Determines if a value lies within the range specified by this bound.
281282 pub fn in_bounds ( & self , value : & T ) -> bool {
282- match ( self . type_ , BoundSided :: side ( None :: < S > ) ) {
283+ match ( self . type_ , < S as BoundSided > :: side ( ) ) {
283284 ( Inclusive , Upper ) => value <= & self . value ,
284285 ( Exclusive , Upper ) => value < & self . value ,
285286 ( Inclusive , Lower ) => value >= & self . value ,
@@ -304,7 +305,7 @@ impl<'a, S, T> PartialEq for OptBound<'a, S, T> where S: BoundSided, T: PartialE
304305
305306impl < ' a , S , T > PartialOrd for OptBound < ' a , S , T > where S : BoundSided , T : PartialOrd {
306307 fn partial_cmp ( & self , other : & OptBound < ' a , S , T > ) -> Option < Ordering > {
307- match ( self , other, BoundSided :: side ( None :: < S > ) ) {
308+ match ( self , other, < S as BoundSided > :: side ( ) ) {
308309 ( & OptBound ( None ) , & OptBound ( None ) , _) => Some ( Ordering :: Equal ) ,
309310 ( & OptBound ( None ) , _, Lower )
310311 | ( _, & OptBound ( None ) , Upper ) => Some ( Ordering :: Less ) ,
0 commit comments