11//! Types dealing with ranges of values
22#![ doc( html_root_url = "https://sfackler.github.io/rust-postgres-range/doc/v0.9" ) ]
3+ #![ warn( clippy:: all, rust_2018_idioms, missing_docs) ]
34
4- extern crate postgres_protocol;
55#[ macro_use( to_sql_checked) ]
66extern crate postgres_types;
77
88#[ cfg( feature = "with-chrono-0_4" ) ]
99mod chrono_04;
1010
11- #[ cfg( test) ]
12- extern crate postgres;
13-
1411use std:: cmp:: Ordering ;
1512use std:: fmt;
1613use std:: i32;
@@ -222,7 +219,7 @@ where
222219 fn clone ( & self ) -> RangeBound < S , T > {
223220 RangeBound {
224221 value : self . value . clone ( ) ,
225- type_ : self . type_ . clone ( ) ,
222+ type_ : self . type_ ,
226223 _m : PhantomData ,
227224 }
228225 }
@@ -233,7 +230,7 @@ where
233230 S : BoundSided ,
234231 T : fmt:: Debug ,
235232{
236- fn fmt ( & self , fmt : & mut fmt:: Formatter ) -> fmt:: Result {
233+ fn fmt ( & self , fmt : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
237234 fmt. debug_struct ( "RangeBound" )
238235 . field ( "value" , & self . value )
239236 . field ( "type_" , & self . type_ )
@@ -246,7 +243,7 @@ where
246243 S : BoundSided ,
247244 T : fmt:: Display ,
248245{
249- fn fmt ( & self , fmt : & mut fmt:: Formatter ) -> fmt:: Result {
246+ fn fmt ( & self , fmt : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
250247 let ( lower, upper) = match self . type_ {
251248 Inclusive => ( '[' , ']' ) ,
252249 Exclusive => ( '(' , ')' ) ,
@@ -268,9 +265,9 @@ where
268265 self . value == other. value && self . type_ == other. type_
269266 }
270267
271- fn ne ( & self , other : & RangeBound < S , T > ) -> bool {
268+ /* fn ne(&self, other: &RangeBound<S, T>) -> bool {
272269 self.value != other.value || self.type_ != other.type_
273- }
270+ }*/
274271}
275272
276273impl < S , T > Eq for RangeBound < S , T >
@@ -326,8 +323,8 @@ where
326323 /// Constructs a new range bound
327324 pub fn new ( value : T , type_ : BoundType ) -> RangeBound < S , T > {
328325 RangeBound {
329- value : value ,
330- type_ : type_ ,
326+ value,
327+ type_,
331328 _m : PhantomData ,
332329 }
333330 }
@@ -343,7 +340,7 @@ where
343340 }
344341}
345342
346- struct OptBound < ' a , S : ' a + BoundSided , T : ' a > ( Option < & ' a RangeBound < S , T > > ) ;
343+ struct OptBound < ' a , S : BoundSided , T > ( Option < & ' a RangeBound < S , T > > ) ;
347344
348345impl < ' a , S , T > PartialEq for OptBound < ' a , S , T >
349346where
@@ -355,10 +352,10 @@ where
355352 self_ == other
356353 }
357354
358- fn ne ( & self , & OptBound ( ref other) : & OptBound < ' a , S , T > ) -> bool {
355+ /* fn ne(&self, &OptBound(ref other): &OptBound<'a, S, T>) -> bool {
359356 let &OptBound(ref self_) = self;
360357 self_ != other
361- }
358+ }*/
362359}
363360
364361impl < ' a , S , T > PartialOrd for OptBound < ' a , S , T >
@@ -395,7 +392,7 @@ impl<T> fmt::Display for Range<T>
395392where
396393 T : fmt:: Display ,
397394{
398- fn fmt ( & self , fmt : & mut fmt:: Formatter ) -> fmt:: Result {
395+ fn fmt ( & self , fmt : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
399396 match self . inner {
400397 Empty => write ! ( fmt, "empty" ) ,
401398 Normal ( ref lower, ref upper) => {
@@ -520,7 +517,7 @@ where
520517 let ( _, OptBound ( lower) ) = order ( OptBound ( self . lower ( ) ) , OptBound ( other. lower ( ) ) ) ;
521518 let ( OptBound ( upper) , _) = order ( OptBound ( self . upper ( ) ) , OptBound ( other. upper ( ) ) ) ;
522519
523- Range :: new ( lower. map ( |v| v . clone ( ) ) , upper. map ( |v| v . clone ( ) ) )
520+ Range :: new ( lower. cloned ( ) , upper. cloned ( ) )
524521 }
525522
526523 /// Returns the union of this range with another if it is contiguous.
@@ -557,8 +554,8 @@ where
557554 None
558555 } else {
559556 Some ( Range :: new (
560- l_lower. map ( |v| v . clone ( ) ) ,
561- u_upper. map ( |v| v . clone ( ) ) ,
557+ l_lower. cloned ( ) ,
558+ u_upper. cloned ( ) ,
562559 ) )
563560 }
564561 }
@@ -720,7 +717,7 @@ mod test {
720717 assert_eq ! ( r1, ( range!( '(' , ; ')' ) ) . intersect( & r1) ) ;
721718
722719 let r2 = range ! ( '(' 10i32 , ; ')' ) ;
723- let exp = Range :: new ( r2. lower ( ) . map ( |v| v . clone ( ) ) , r1. upper ( ) . map ( |v| v . clone ( ) ) ) ;
720+ let exp = Range :: new ( r2. lower ( ) . copied ( ) , r1. upper ( ) . copied ( ) ) ;
724721 assert_eq ! ( exp, r1. intersect( & r2) ) ;
725722 assert_eq ! ( exp, r2. intersect( & r1) ) ;
726723
0 commit comments