diff --git a/Cargo.toml b/Cargo.toml index b673280..fb06f60 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,6 +9,7 @@ license = "MIT/Apache-2.0" repository = "https://github.com/rust-num/num-traits" name = "num-traits" version = "0.2.8" +edition = "2018" readme = "README.md" build = "build.rs" exclude = ["/ci/*", "/.travis.yml", "/bors.toml"] diff --git a/src/bounds.rs b/src/bounds.rs index a133d7a..c9ff749 100644 --- a/src/bounds.rs +++ b/src/bounds.rs @@ -95,8 +95,8 @@ fn wrapping_bounded() { macro_rules! test_wrapping_bounded { ($($t:ty)+) => { $( - assert_eq!(Wrapping::<$t>::min_value().0, <$t>::min_value()); - assert_eq!(Wrapping::<$t>::max_value().0, <$t>::max_value()); + assert_eq!( as Bounded>::min_value().0, <$t>::min_value()); + assert_eq!( as Bounded>::max_value().0, <$t>::max_value()); )+ }; } @@ -110,8 +110,8 @@ fn wrapping_bounded_i128() { macro_rules! test_wrapping_bounded { ($($t:ty)+) => { $( - assert_eq!(Wrapping::<$t>::min_value().0, <$t>::min_value()); - assert_eq!(Wrapping::<$t>::max_value().0, <$t>::max_value()); + assert_eq!( as Bounded>::min_value().0, <$t>::min_value()); + assert_eq!( as Bounded>::max_value().0, <$t>::max_value()); )+ }; } diff --git a/src/cast.rs b/src/cast.rs index 20e9340..6022eff 100644 --- a/src/cast.rs +++ b/src/cast.rs @@ -6,7 +6,7 @@ use core::{i128, u128}; use core::{i16, i32, i64, i8, isize}; use core::{u16, u32, u64, u8, usize}; -use float::FloatCore; +use crate::float::FloatCore; /// A generic trait for converting a value to a number. pub trait ToPrimitive { diff --git a/src/float.rs b/src/float.rs index c91233c..7d1ba9d 100644 --- a/src/float.rs +++ b/src/float.rs @@ -5,7 +5,7 @@ use core::ops::Neg; use core::f32; use core::f64; -use {Num, NumCast, ToPrimitive}; +use crate::{Num, NumCast, ToPrimitive}; /// Generic trait for floating point numbers that works with `no_std`. /// @@ -1982,7 +1982,7 @@ mod tests { #[test] fn convert_deg_rad() { - use float::FloatCore; + use crate::float::FloatCore; for &(deg, rad) in &DEG_RAD_PAIRS { assert!((FloatCore::to_degrees(rad) - deg).abs() < 1e-6); @@ -1998,7 +1998,7 @@ mod tests { #[test] fn convert_deg_rad_std() { for &(deg, rad) in &DEG_RAD_PAIRS { - use Float; + use crate::Float; assert!((Float::to_degrees(rad) - deg).abs() < 1e-6); assert!((Float::to_radians(deg) - rad).abs() < 1e-6); diff --git a/src/int.rs b/src/int.rs index 26d5a9a..39412ee 100644 --- a/src/int.rs +++ b/src/int.rs @@ -1,9 +1,9 @@ use core::ops::{BitAnd, BitOr, BitXor, Not, Shl, Shr}; -use bounds::Bounded; -use ops::checked::*; -use ops::saturating::Saturating; -use {Num, NumCast}; +use crate::bounds::Bounded; +use crate::ops::checked::*; +use crate::ops::saturating::Saturating; +use crate::{Num, NumCast}; /// Generic trait for primitive integers. /// diff --git a/src/lib.rs b/src/lib.rs index 172e714..4e4060d 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -16,9 +16,7 @@ #![doc(html_root_url = "https://docs.rs/num-traits/0.2")] #![deny(unconditional_recursion)] -#![no_std] -#[cfg(feature = "std")] -extern crate std; +#![cfg_attr(not(feature = "std"), no_std)] use core::fmt; use core::num::Wrapping; diff --git a/src/pow.rs b/src/pow.rs index daecb8e..b45dc4c 100644 --- a/src/pow.rs +++ b/src/pow.rs @@ -1,6 +1,6 @@ use core::num::Wrapping; use core::ops::Mul; -use {CheckedMul, One}; +use crate::{CheckedMul, One}; /// Binary operator for raising a value to a power. pub trait Pow { diff --git a/src/real.rs b/src/real.rs index 23ac6b8..7281637 100644 --- a/src/real.rs +++ b/src/real.rs @@ -1,6 +1,6 @@ use std::ops::Neg; -use {Float, Num, NumCast}; +use crate::{Float, Num, NumCast}; // NOTE: These doctests have the same issue as those in src/float.rs. // They're testing the inherent methods directly, and not those of `Real`. diff --git a/src/sign.rs b/src/sign.rs index 26d44c5..26b4e25 100644 --- a/src/sign.rs +++ b/src/sign.rs @@ -1,8 +1,8 @@ use core::num::Wrapping; use core::ops::Neg; -use float::FloatCore; -use Num; +use crate::float::FloatCore; +use crate::Num; /// Useful functions for signed numbers (i.e. numbers that can be negative). pub trait Signed: Sized + Num + Neg {