@@ -10,6 +10,8 @@ use std::cmp::Ordering;
1010use std:: fmt;
1111use std:: i32;
1212use std:: i64;
13+ use std:: marker:: MarkerTrait ;
14+ use std:: marker:: PhantomData ;
1315
1416use time:: Timespec ;
1517
@@ -164,7 +166,7 @@ pub enum BoundSide {
164166
165167/// A trait implemented by phantom types indicating the type of the bound
166168#[ doc( hidden) ]
167- pub trait BoundSided {
169+ pub trait BoundSided : MarkerTrait {
168170 /// Returns the bound side this type corresponds to
169171 fn side ( ) -> BoundSide ;
170172}
@@ -205,7 +207,8 @@ pub struct RangeBound<S: BoundSided, T> {
205207 /// The value of the bound
206208 pub value : T ,
207209 /// The type of the bound
208- pub type_ : BoundType
210+ pub type_ : BoundType ,
211+ _m : PhantomData < * mut S > ,
209212}
210213
211214impl < S , T > Copy for RangeBound < S , T > where S : BoundSided , T : Copy { }
@@ -215,6 +218,7 @@ impl<S, T> Clone for RangeBound<S, T> where S: BoundSided, T: Clone {
215218 RangeBound {
216219 value : self . value . clone ( ) ,
217220 type_ : self . type_ . clone ( ) ,
221+ _m : PhantomData ,
218222 }
219223 }
220224}
@@ -274,7 +278,11 @@ impl<S, T> Ord for RangeBound<S, T> where S: BoundSided, T: Ord {
274278impl < S , T > RangeBound < S , T > where S : BoundSided , T : PartialOrd {
275279 /// Constructs a new range bound
276280 pub fn new ( value : T , type_ : BoundType ) -> RangeBound < S , T > {
277- RangeBound { value : value, type_ : type_ }
281+ RangeBound {
282+ value : value,
283+ type_ : type_,
284+ _m : PhantomData ,
285+ }
278286 }
279287
280288 /// Determines if a value lies within the range specified by this bound.
@@ -288,7 +296,7 @@ impl<S, T> RangeBound<S, T> where S: BoundSided, T: PartialOrd {
288296 }
289297}
290298
291- struct OptBound < ' a , S : BoundSided , T : ' a > ( Option < & ' a RangeBound < S , T > > ) ;
299+ struct OptBound < ' a , S : ' a + BoundSided , T : ' a > ( Option < & ' a RangeBound < S , T > > ) ;
292300
293301impl < ' a , S , T > PartialEq for OptBound < ' a , S , T > where S : BoundSided , T : PartialEq {
294302 fn eq ( & self , & OptBound ( ref other) : & OptBound < ' a , S , T > ) -> bool {
@@ -463,8 +471,8 @@ impl<T> Range<T> where T: PartialOrd+Normalizable+Clone {
463471 order ( OptBound ( self . upper ( ) ) , OptBound ( other. upper ( ) ) ) ;
464472
465473 let discontiguous = match ( u_lower, l_upper) {
466- ( Some ( & RangeBound { value : ref l, type_ : Exclusive } ) ,
467- Some ( & RangeBound { value : ref u, type_ : Exclusive } ) ) => l >= u,
474+ ( Some ( & RangeBound { value : ref l, type_ : Exclusive , .. } ) ,
475+ Some ( & RangeBound { value : ref u, type_ : Exclusive , .. } ) ) => l >= u,
468476 ( Some ( & RangeBound { value : ref l, .. } ) ,
469477 Some ( & RangeBound { value : ref u, .. } ) ) => l > u,
470478 _ => false
0 commit comments