Skip to content

Commit da2bd55

Browse files
committed
Upgrade to 2018 edition
1 parent 6d50d5d commit da2bd55

File tree

11 files changed

+47
-53
lines changed

11 files changed

+47
-53
lines changed

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ version = "0.2.15"
1212
readme = "README.md"
1313
build = "build.rs"
1414
exclude = ["/bors.toml", "/ci/*", "/.github/*"]
15+
edition = "2018"
1516

1617
[package.metadata.docs.rs]
1718
features = ["std"]

build.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
extern crate autocfg;
2-
31
use std::env;
42

53
fn main() {

src/float.rs

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,7 @@ use core::ops::{Add, Div, Neg};
55
use core::f32;
66
use core::f64;
77

8-
use {Num, NumCast, ToPrimitive};
9-
10-
#[cfg(all(not(feature = "std"), feature = "libm"))]
11-
use libm;
8+
use crate::{Num, NumCast, ToPrimitive};
129

1310
/// Generic trait for floating point numbers that works with `no_std`.
1411
///
@@ -2244,7 +2241,7 @@ mod tests {
22442241

22452242
#[test]
22462243
fn convert_deg_rad() {
2247-
use float::FloatCore;
2244+
use crate::float::FloatCore;
22482245

22492246
for &(deg, rad) in &DEG_RAD_PAIRS {
22502247
assert!((FloatCore::to_degrees(rad) - deg).abs() < 1e-6);
@@ -2260,7 +2257,7 @@ mod tests {
22602257
#[test]
22612258
fn convert_deg_rad_std() {
22622259
for &(deg, rad) in &DEG_RAD_PAIRS {
2263-
use Float;
2260+
use crate::Float;
22642261

22652262
assert!((Float::to_degrees(rad) - deg).abs() < 1e-6);
22662263
assert!((Float::to_radians(deg) - rad).abs() < 1e-6);
@@ -2276,7 +2273,7 @@ mod tests {
22762273
// To avoid the failure, the test is limited to `no_std` builds.
22772274
#[cfg(not(feature = "std"))]
22782275
fn to_degrees_rounding() {
2279-
use float::FloatCore;
2276+
use crate::float::FloatCore;
22802277

22812278
assert_eq!(
22822279
FloatCore::to_degrees(1_f32),
@@ -2287,7 +2284,7 @@ mod tests {
22872284
#[test]
22882285
#[cfg(any(feature = "std", feature = "libm"))]
22892286
fn extra_logs() {
2290-
use float::{Float, FloatConst};
2287+
use crate::float::{Float, FloatConst};
22912288

22922289
fn check<F: Float + FloatConst>(diff: F) {
22932290
let _2 = F::from(2.0).unwrap();
@@ -2306,16 +2303,16 @@ mod tests {
23062303
#[test]
23072304
#[cfg(any(feature = "std", feature = "libm"))]
23082305
fn copysign() {
2309-
use float::Float;
2306+
use crate::float::Float;
23102307
test_copysign_generic(2.0_f32, -2.0_f32, f32::nan());
23112308
test_copysign_generic(2.0_f64, -2.0_f64, f64::nan());
23122309
test_copysignf(2.0_f32, -2.0_f32, f32::nan());
23132310
}
23142311

23152312
#[cfg(any(feature = "std", feature = "libm"))]
23162313
fn test_copysignf(p: f32, n: f32, nan: f32) {
2314+
use crate::float::Float;
23172315
use core::ops::Neg;
2318-
use float::Float;
23192316

23202317
assert!(p.is_sign_positive());
23212318
assert!(n.is_sign_negative());
@@ -2333,7 +2330,7 @@ mod tests {
23332330
}
23342331

23352332
#[cfg(any(feature = "std", feature = "libm"))]
2336-
fn test_copysign_generic<F: ::float::Float + ::core::fmt::Debug>(p: F, n: F, nan: F) {
2333+
fn test_copysign_generic<F: crate::float::Float + ::core::fmt::Debug>(p: F, n: F, nan: F) {
23372334
assert!(p.is_sign_positive());
23382335
assert!(n.is_sign_negative());
23392336
assert!(nan.is_nan());

src/int.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
use core::ops::{BitAnd, BitOr, BitXor, Not, Shl, Shr};
22

3-
use bounds::Bounded;
4-
use ops::checked::*;
5-
use ops::saturating::Saturating;
6-
use {Num, NumCast};
3+
use crate::bounds::Bounded;
4+
use crate::ops::checked::*;
5+
use crate::ops::saturating::Saturating;
6+
use crate::{Num, NumCast};
77

88
/// Generic trait for primitive integers.
99
///
@@ -513,7 +513,7 @@ prim_int_impl!(isize, isize, usize);
513513

514514
#[cfg(test)]
515515
mod tests {
516-
use int::PrimInt;
516+
use crate::int::PrimInt;
517517

518518
#[test]
519519
pub fn reverse_bits() {

src/lib.rs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -29,26 +29,26 @@ use core::num::Wrapping;
2929
use core::ops::{Add, Div, Mul, Rem, Sub};
3030
use core::ops::{AddAssign, DivAssign, MulAssign, RemAssign, SubAssign};
3131

32-
pub use bounds::Bounded;
32+
pub use crate::bounds::Bounded;
3333
#[cfg(any(feature = "std", feature = "libm"))]
34-
pub use float::Float;
35-
pub use float::FloatConst;
34+
pub use crate::float::Float;
35+
pub use crate::float::FloatConst;
3636
// pub use real::{FloatCore, Real}; // NOTE: Don't do this, it breaks `use num_traits::*;`.
37-
pub use cast::{cast, AsPrimitive, FromPrimitive, NumCast, ToPrimitive};
38-
pub use identities::{one, zero, One, Zero};
39-
pub use int::PrimInt;
40-
pub use ops::checked::{
37+
pub use crate::cast::{cast, AsPrimitive, FromPrimitive, NumCast, ToPrimitive};
38+
pub use crate::identities::{one, zero, One, Zero};
39+
pub use crate::int::PrimInt;
40+
pub use crate::ops::checked::{
4141
CheckedAdd, CheckedDiv, CheckedMul, CheckedNeg, CheckedRem, CheckedShl, CheckedShr, CheckedSub,
4242
};
43-
pub use ops::euclid::{CheckedEuclid, Euclid};
44-
pub use ops::inv::Inv;
45-
pub use ops::mul_add::{MulAdd, MulAddAssign};
46-
pub use ops::saturating::{Saturating, SaturatingAdd, SaturatingMul, SaturatingSub};
47-
pub use ops::wrapping::{
43+
pub use crate::ops::euclid::{CheckedEuclid, Euclid};
44+
pub use crate::ops::inv::Inv;
45+
pub use crate::ops::mul_add::{MulAdd, MulAddAssign};
46+
pub use crate::ops::saturating::{Saturating, SaturatingAdd, SaturatingMul, SaturatingSub};
47+
pub use crate::ops::wrapping::{
4848
WrappingAdd, WrappingMul, WrappingNeg, WrappingShl, WrappingShr, WrappingSub,
4949
};
50-
pub use pow::{checked_pow, pow, Pow};
51-
pub use sign::{abs, abs_sub, signum, Signed, Unsigned};
50+
pub use crate::pow::{checked_pow, pow, Pow};
51+
pub use crate::sign::{abs, abs_sub, signum, Signed, Unsigned};
5252

5353
#[macro_use]
5454
mod macros;
@@ -199,7 +199,7 @@ pub struct ParseFloatError {
199199
}
200200

201201
impl fmt::Display for ParseFloatError {
202-
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
202+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
203203
let description = match self.kind {
204204
FloatErrorKind::Empty => "cannot parse float from empty string",
205205
FloatErrorKind::Invalid => "invalid float literal",

src/ops/euclid.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ euclid_forward_impl!(f32 f64);
130130
impl Euclid for f32 {
131131
#[inline]
132132
fn div_euclid(&self, v: &f32) -> f32 {
133-
let q = <f32 as ::float::FloatCore>::trunc(self / v);
133+
let q = <f32 as crate::float::FloatCore>::trunc(self / v);
134134
if self % v < 0.0 {
135135
return if *v > 0.0 { q - 1.0 } else { q + 1.0 };
136136
}
@@ -141,7 +141,7 @@ impl Euclid for f32 {
141141
fn rem_euclid(&self, v: &f32) -> f32 {
142142
let r = self % v;
143143
if r < 0.0 {
144-
r + <f32 as ::float::FloatCore>::abs(*v)
144+
r + <f32 as crate::float::FloatCore>::abs(*v)
145145
} else {
146146
r
147147
}
@@ -152,7 +152,7 @@ impl Euclid for f32 {
152152
impl Euclid for f64 {
153153
#[inline]
154154
fn div_euclid(&self, v: &f64) -> f64 {
155-
let q = <f64 as ::float::FloatCore>::trunc(self / v);
155+
let q = <f64 as crate::float::FloatCore>::trunc(self / v);
156156
if self % v < 0.0 {
157157
return if *v > 0.0 { q - 1.0 } else { q + 1.0 };
158158
}
@@ -163,7 +163,7 @@ impl Euclid for f64 {
163163
fn rem_euclid(&self, v: &f64) -> f64 {
164164
let r = self % v;
165165
if r < 0.0 {
166-
r + <f64 as ::float::FloatCore>::abs(*v)
166+
r + <f64 as crate::float::FloatCore>::abs(*v)
167167
} else {
168168
r
169169
}
@@ -312,13 +312,13 @@ mod tests {
312312
let x: $t = 12.1;
313313
let y: $t = 3.2;
314314
assert!(Euclid::div_euclid(&x, &y) * y + Euclid::rem_euclid(&x, &y) - x
315-
<= 46.4 * <$t as ::float::FloatCore>::epsilon());
315+
<= 46.4 * <$t as crate::float::FloatCore>::epsilon());
316316
assert!(Euclid::div_euclid(&x, &-y) * -y + Euclid::rem_euclid(&x, &-y) - x
317-
<= 46.4 * <$t as ::float::FloatCore>::epsilon());
317+
<= 46.4 * <$t as crate::float::FloatCore>::epsilon());
318318
assert!(Euclid::div_euclid(&-x, &y) * y + Euclid::rem_euclid(&-x, &y) + x
319-
<= 46.4 * <$t as ::float::FloatCore>::epsilon());
319+
<= 46.4 * <$t as crate::float::FloatCore>::epsilon());
320320
assert!(Euclid::div_euclid(&-x, &-y) * -y + Euclid::rem_euclid(&-x, &-y) + x
321-
<= 46.4 * <$t as ::float::FloatCore>::epsilon());
321+
<= 46.4 * <$t as crate::float::FloatCore>::epsilon());
322322
}
323323
)+
324324
};

src/ops/mul_add.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ impl MulAdd<f32, f32> for f32 {
4040

4141
#[inline]
4242
fn mul_add(self, a: Self, b: Self) -> Self::Output {
43-
<Self as ::Float>::mul_add(self, a, b)
43+
<Self as crate::Float>::mul_add(self, a, b)
4444
}
4545
}
4646

@@ -50,7 +50,7 @@ impl MulAdd<f64, f64> for f64 {
5050

5151
#[inline]
5252
fn mul_add(self, a: Self, b: Self) -> Self::Output {
53-
<Self as ::Float>::mul_add(self, a, b)
53+
<Self as crate::Float>::mul_add(self, a, b)
5454
}
5555
}
5656

@@ -75,15 +75,15 @@ mul_add_impl!(MulAdd for i128 u128);
7575
impl MulAddAssign<f32, f32> for f32 {
7676
#[inline]
7777
fn mul_add_assign(&mut self, a: Self, b: Self) {
78-
*self = <Self as ::Float>::mul_add(*self, a, b)
78+
*self = <Self as crate::Float>::mul_add(*self, a, b)
7979
}
8080
}
8181

8282
#[cfg(any(feature = "std", feature = "libm"))]
8383
impl MulAddAssign<f64, f64> for f64 {
8484
#[inline]
8585
fn mul_add_assign(&mut self, a: Self, b: Self) {
86-
*self = <Self as ::Float>::mul_add(*self, a, b)
86+
*self = <Self as crate::Float>::mul_add(*self, a, b)
8787
}
8888
}
8989

src/pow.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1+
use crate::{CheckedMul, One};
12
use core::num::Wrapping;
23
use core::ops::Mul;
3-
use {CheckedMul, One};
44

55
/// Binary operator for raising a value to a power.
66
pub trait Pow<RHS> {
@@ -155,7 +155,7 @@ pow_impl!(Wrapping<isize>);
155155
#[cfg(any(feature = "std", feature = "libm"))]
156156
mod float_impls {
157157
use super::Pow;
158-
use Float;
158+
use crate::Float;
159159

160160
pow_impl!(f32, i8, i32, <f32 as Float>::powi);
161161
pow_impl!(f32, u8, i32, <f32 as Float>::powi);

src/real.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
use core::ops::Neg;
44

5-
use {Float, Num, NumCast};
5+
use crate::{Float, Num, NumCast};
66

77
// NOTE: These doctests have the same issue as those in src/float.rs.
88
// They're testing the inherent methods directly, and not those of `Real`.

src/sign.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
use core::num::Wrapping;
22
use core::ops::Neg;
33

4-
use float::FloatCore;
5-
use Num;
4+
use crate::float::FloatCore;
5+
use crate::Num;
66

77
/// Useful functions for signed numbers (i.e. numbers that can be negative).
88
pub trait Signed: Sized + Num + Neg<Output = Self> {

0 commit comments

Comments
 (0)