@@ -23,12 +23,6 @@ extern crate std;
2323
2424extern crate num_traits as traits;
2525
26- #[ cfg( feature = "serde" ) ]
27- extern crate serde;
28-
29- #[ cfg( feature = "rand" ) ]
30- extern crate rand;
31-
3226use core:: fmt;
3327#[ cfg( test) ]
3428use core:: hash;
@@ -38,19 +32,19 @@ use core::str::FromStr;
3832#[ cfg( feature = "std" ) ]
3933use std:: error:: Error ;
4034
41- use traits:: { Inv , MulAdd , Num , One , Pow , Signed , Zero } ;
35+ use crate :: traits:: { Inv , MulAdd , Num , One , Pow , Signed , Zero } ;
4236
4337#[ cfg( feature = "std" ) ]
44- use traits:: float:: Float ;
45- use traits:: float:: FloatCore ;
38+ use crate :: traits:: float:: Float ;
39+ use crate :: traits:: float:: FloatCore ;
4640
4741mod cast;
4842mod pow;
4943
5044#[ cfg( feature = "rand" ) ]
5145mod crand;
5246#[ cfg( feature = "rand" ) ]
53- pub use crand:: ComplexDistribution ;
47+ pub use crate :: crand:: ComplexDistribution ;
5448
5549// FIXME #1284: handle complex NaN & infinity etc. This
5650// probably doesn't map to C's _Complex correctly.
@@ -759,9 +753,9 @@ impl<T: Clone + Num> Rem<Complex<T>> for Complex<T> {
759753mod opassign {
760754 use core:: ops:: { AddAssign , DivAssign , MulAssign , RemAssign , SubAssign } ;
761755
762- use traits:: { MulAddAssign , NumAssign } ;
756+ use crate :: traits:: { MulAddAssign , NumAssign } ;
763757
764- use Complex ;
758+ use crate :: Complex ;
765759
766760 impl < T : Clone + NumAssign > AddAssign for Complex < T > {
767761 fn add_assign ( & mut self , other : Self ) {
@@ -1149,11 +1143,11 @@ macro_rules! write_complex {
11491143 } ;
11501144
11511145 fn fmt_re_im(
1152- f: & mut fmt:: Formatter ,
1146+ f: & mut fmt:: Formatter < ' _> ,
11531147 re_neg: bool ,
11541148 im_neg: bool ,
1155- real: fmt:: Arguments ,
1156- imag: fmt:: Arguments ,
1149+ real: fmt:: Arguments < ' _> ,
1150+ imag: fmt:: Arguments < ' _> ,
11571151 ) -> fmt:: Result {
11581152 let prefix = if f. alternate( ) { $prefix } else { "" } ;
11591153 let sign = if re_neg {
@@ -1191,7 +1185,7 @@ macro_rules! write_complex {
11911185
11921186 #[ cfg( feature = "std" ) ]
11931187 // Currently, we can only apply width using an intermediate `String` (and thus `std`)
1194- fn fmt_complex( f: & mut fmt:: Formatter , complex: fmt:: Arguments ) -> fmt:: Result {
1188+ fn fmt_complex( f: & mut fmt:: Formatter < ' _> , complex: fmt:: Arguments < ' _> ) -> fmt:: Result {
11951189 use std:: string:: ToString ;
11961190 if let Some ( width) = f. width( ) {
11971191 write!( f, "{0: >1$}" , complex. to_string( ) , width)
@@ -1201,7 +1195,7 @@ macro_rules! write_complex {
12011195 }
12021196
12031197 #[ cfg( not( feature = "std" ) ) ]
1204- fn fmt_complex( f: & mut fmt:: Formatter , complex: fmt:: Arguments ) -> fmt:: Result {
1198+ fn fmt_complex( f: & mut fmt:: Formatter < ' _> , complex: fmt:: Arguments < ' _> ) -> fmt:: Result {
12051199 write!( f, "{}" , complex)
12061200 }
12071201 } } ;
@@ -1212,7 +1206,7 @@ impl<T> fmt::Display for Complex<T>
12121206where
12131207 T : fmt:: Display + Num + PartialOrd + Clone ,
12141208{
1215- fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
1209+ fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
12161210 write_complex ! ( f, "" , "" , self . re, self . im, T )
12171211 }
12181212}
@@ -1221,7 +1215,7 @@ impl<T> fmt::LowerExp for Complex<T>
12211215where
12221216 T : fmt:: LowerExp + Num + PartialOrd + Clone ,
12231217{
1224- fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
1218+ fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
12251219 write_complex ! ( f, "e" , "" , self . re, self . im, T )
12261220 }
12271221}
@@ -1230,7 +1224,7 @@ impl<T> fmt::UpperExp for Complex<T>
12301224where
12311225 T : fmt:: UpperExp + Num + PartialOrd + Clone ,
12321226{
1233- fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
1227+ fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
12341228 write_complex ! ( f, "E" , "" , self . re, self . im, T )
12351229 }
12361230}
@@ -1239,7 +1233,7 @@ impl<T> fmt::LowerHex for Complex<T>
12391233where
12401234 T : fmt:: LowerHex + Num + PartialOrd + Clone ,
12411235{
1242- fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
1236+ fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
12431237 write_complex ! ( f, "x" , "0x" , self . re, self . im, T )
12441238 }
12451239}
@@ -1248,7 +1242,7 @@ impl<T> fmt::UpperHex for Complex<T>
12481242where
12491243 T : fmt:: UpperHex + Num + PartialOrd + Clone ,
12501244{
1251- fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
1245+ fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
12521246 write_complex ! ( f, "X" , "0x" , self . re, self . im, T )
12531247 }
12541248}
@@ -1257,7 +1251,7 @@ impl<T> fmt::Octal for Complex<T>
12571251where
12581252 T : fmt:: Octal + Num + PartialOrd + Clone ,
12591253{
1260- fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
1254+ fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
12611255 write_complex ! ( f, "o" , "0o" , self . re, self . im, T )
12621256 }
12631257}
@@ -1266,7 +1260,7 @@ impl<T> fmt::Binary for Complex<T>
12661260where
12671261 T : fmt:: Binary + Num + PartialOrd + Clone ,
12681262{
1269- fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
1263+ fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
12701264 write_complex ! ( f, "b" , "0b" , self . re, self . im, T )
12711265 }
12721266}
@@ -1351,7 +1345,7 @@ where
13511345 }
13521346
13531347 // parse re
1354- let re = try!( from ( re) . map_err ( ParseComplexError :: from_error) ) ;
1348+ let re = r# try! ( from( re) . map_err( ParseComplexError :: from_error) ) ;
13551349 let re = if neg_re { T :: zero ( ) - re } else { re } ;
13561350
13571351 // pop imaginary unit off
@@ -1364,7 +1358,7 @@ where
13641358 }
13651359
13661360 // parse im
1367- let im = try!( from ( im) . map_err ( ParseComplexError :: from_error) ) ;
1361+ let im = r# try! ( from( im) . map_err( ParseComplexError :: from_error) ) ;
13681362 let im = if neg_im { T :: zero ( ) - im } else { im } ;
13691363
13701364 Ok ( Complex :: new ( re, im) )
@@ -1451,7 +1445,7 @@ where
14511445 where
14521446 D : serde:: Deserializer < ' de > ,
14531447 {
1454- let ( re, im) = try!( serde:: Deserialize :: deserialize ( deserializer) ) ;
1448+ let ( re, im) = r# try! ( serde:: Deserialize :: deserialize( deserializer) ) ;
14551449 Ok ( Self :: new ( re, im) )
14561450 }
14571451}
@@ -1492,7 +1486,7 @@ impl<E: Error> Error for ParseComplexError<E> {
14921486}
14931487
14941488impl < E : fmt:: Display > fmt:: Display for ParseComplexError < E > {
1495- fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
1489+ fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
14961490 match self . kind {
14971491 ComplexErrorKind :: ParseError ( ref e) => e. fmt ( f) ,
14981492 ComplexErrorKind :: ExprError => "invalid or unsupported complex expression" . fmt ( f) ,
@@ -1519,7 +1513,7 @@ mod test {
15191513
15201514 use std:: string:: { String , ToString } ;
15211515
1522- use traits:: { Num , One , Zero } ;
1516+ use crate :: traits:: { Num , One , Zero } ;
15231517
15241518 pub const _0_0i: Complex64 = Complex { re : 0.0 , im : 0.0 } ;
15251519 pub const _1_0i: Complex64 = Complex { re : 1.0 , im : 0.0 } ;
@@ -1616,7 +1610,7 @@ mod test {
16161610 #[ cfg( feature = "std" ) ]
16171611 mod float {
16181612 use super :: * ;
1619- use traits:: { Float , Pow } ;
1613+ use crate :: traits:: { Float , Pow } ;
16201614
16211615 #[ test]
16221616 #[ cfg_attr( target_arch = "x86" , ignore) ]
@@ -2231,7 +2225,7 @@ mod test {
22312225
22322226 mod complex_arithmetic {
22332227 use super :: { _05_05i, _0_0i, _0_1i, _1_0i, _1_1i, _4_2i, _neg1_1i, all_consts} ;
2234- use traits:: { MulAdd , MulAddAssign , Zero } ;
2228+ use crate :: traits:: { MulAdd , MulAddAssign , Zero } ;
22352229
22362230 #[ test]
22372231 fn test_add ( ) {
@@ -2450,9 +2444,9 @@ mod test {
24502444 let a = Complex :: new ( 0i32 , 0i32 ) ;
24512445 let b = Complex :: new ( 1i32 , 0i32 ) ;
24522446 let c = Complex :: new ( 0i32 , 1i32 ) ;
2453- assert ! ( :: hash( & a) != :: hash( & b) ) ;
2454- assert ! ( :: hash( & b) != :: hash( & c) ) ;
2455- assert ! ( :: hash( & c) != :: hash( & a) ) ;
2447+ assert ! ( crate :: hash( & a) != crate :: hash( & b) ) ;
2448+ assert ! ( crate :: hash( & b) != crate :: hash( & c) ) ;
2449+ assert ! ( crate :: hash( & c) != crate :: hash( & a) ) ;
24562450 }
24572451
24582452 #[ test]
0 commit comments