From e4609ed89873a9ef2186cce7a20e43d484fc5728 Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Wed, 7 Feb 2024 15:54:26 -0800 Subject: [PATCH 01/12] Use namespaced-features to safely bump to MSRV 1.60 Earlier versions won't see the incompatible updates at all! --- .github/workflows/ci.yaml | 8 +------- .github/workflows/master.yaml | 2 +- .github/workflows/pr.yaml | 2 +- Cargo.toml | 3 ++- ci/rustup.sh | 2 +- ci/test_full.sh | 5 +---- 6 files changed, 7 insertions(+), 15 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index f9bd00b8..c03416ba 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -9,13 +9,7 @@ jobs: strategy: matrix: rust: [ - 1.31.0, # MSRV - 1.35.0, # has_copysign - 1.37.0, # has_reverse_bits - 1.38.0, # has_div_euclid - 1.44.0, # has_to_int_unchecked - 1.46.0, # has_leading_trailing_ones - 1.53.0, # has_is_subnormal + 1.60.0, # MSRV 1.62.0, # has_total_cmp stable, beta, diff --git a/.github/workflows/master.yaml b/.github/workflows/master.yaml index 68c4900d..034e3793 100644 --- a/.github/workflows/master.yaml +++ b/.github/workflows/master.yaml @@ -13,7 +13,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - rust: [1.31.0, stable] + rust: [1.60.0, stable] steps: - uses: actions/checkout@v4 - uses: actions/cache@v4 diff --git a/.github/workflows/pr.yaml b/.github/workflows/pr.yaml index 5004cbbf..ac27bc45 100644 --- a/.github/workflows/pr.yaml +++ b/.github/workflows/pr.yaml @@ -9,7 +9,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - rust: [1.31.0, stable] + rust: [1.60.0, stable] steps: - uses: actions/checkout@v4 - uses: actions/cache@v4 diff --git a/Cargo.toml b/Cargo.toml index 4f494e01..3abe8754 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,7 +13,7 @@ readme = "README.md" build = "build.rs" exclude = ["/ci/*", "/.github/*"] edition = "2018" -rust-version = "1.31" +rust-version = "1.60" [package.metadata.docs.rs] features = ["std"] @@ -24,6 +24,7 @@ libm = { version = "0.2.0", optional = true } [features] default = ["std"] +libm = ["dep:libm"] std = [] # vestigial features, now always in effect diff --git a/ci/rustup.sh b/ci/rustup.sh index 26c8c3db..a07aa610 100755 --- a/ci/rustup.sh +++ b/ci/rustup.sh @@ -5,6 +5,6 @@ set -ex ci=$(dirname $0) -for version in 1.31.0 1.35.0 1.37.0 1.38.0 1.44.0 1.46.0 1.53.0 1.62.0 stable beta nightly; do +for version in 1.60.0 1.62.0 stable beta nightly; do rustup run "$version" "$ci/test_full.sh" done diff --git a/ci/test_full.sh b/ci/test_full.sh index e8c09c14..157756a6 100755 --- a/ci/test_full.sh +++ b/ci/test_full.sh @@ -3,7 +3,7 @@ set -e CRATE=num-traits -MSRV=1.31 +MSRV=1.60 get_rust_version() { local array=($(rustc --version)); @@ -32,9 +32,6 @@ echo "Testing supported features: ${FEATURES[*]}" cargo generate-lockfile -# libm 0.2.6 started using {float}::EPSILON -check_version 1.43 || cargo update -p libm --precise 0.2.5 - set -x # test the default From 3b74d015b95765dd4b4897c9cdef6ab57dc78e78 Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Wed, 7 Feb 2024 15:56:32 -0800 Subject: [PATCH 02/12] Assume has_to_int_unchecked --- build.rs | 5 ----- src/cast.rs | 8 -------- 2 files changed, 13 deletions(-) diff --git a/build.rs b/build.rs index 11bf090a..a706f163 100644 --- a/build.rs +++ b/build.rs @@ -3,11 +3,6 @@ use std::env; fn main() { let ac = autocfg::new(); - ac.emit_expression_cfg( - "unsafe { 1f64.to_int_unchecked::() }", - "has_to_int_unchecked", - ); - ac.emit_expression_cfg("1u32.reverse_bits()", "has_reverse_bits"); ac.emit_expression_cfg("1u32.trailing_ones()", "has_leading_trailing_ones"); ac.emit_expression_cfg("1u32.div_euclid(1u32)", "has_div_euclid"); diff --git a/src/cast.rs b/src/cast.rs index 125e2e38..a3e4dd8b 100644 --- a/src/cast.rs +++ b/src/cast.rs @@ -277,7 +277,6 @@ macro_rules! impl_to_primitive_float_to_float { )*} } -#[cfg(has_to_int_unchecked)] macro_rules! float_to_int_unchecked { // SAFETY: Must not be NaN or infinite; must be representable as the integer after truncating. // We already checked that the float is in the exclusive range `(MIN-1, MAX+1)`. @@ -286,13 +285,6 @@ macro_rules! float_to_int_unchecked { }; } -#[cfg(not(has_to_int_unchecked))] -macro_rules! float_to_int_unchecked { - ($float:expr => $int:ty) => { - $float as $int - }; -} - macro_rules! impl_to_primitive_float_to_signed_int { ($f:ident : $( $(#[$cfg:meta])* fn $method:ident -> $i:ident ; )*) => {$( #[inline] From 2c012d5f2c19b7a912e5c8e77ae065c3f931297f Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Wed, 7 Feb 2024 15:57:28 -0800 Subject: [PATCH 03/12] Assume has_reverse_bits --- build.rs | 1 - src/int.rs | 1 - 2 files changed, 2 deletions(-) diff --git a/build.rs b/build.rs index a706f163..205b8576 100644 --- a/build.rs +++ b/build.rs @@ -3,7 +3,6 @@ use std::env; fn main() { let ac = autocfg::new(); - ac.emit_expression_cfg("1u32.reverse_bits()", "has_reverse_bits"); ac.emit_expression_cfg("1u32.trailing_ones()", "has_leading_trailing_ones"); ac.emit_expression_cfg("1u32.div_euclid(1u32)", "has_div_euclid"); diff --git a/src/int.rs b/src/int.rs index e3ca72c0..7669130e 100644 --- a/src/int.rs +++ b/src/int.rs @@ -461,7 +461,6 @@ macro_rules! prim_int_impl { <$T>::swap_bytes(self) } - #[cfg(has_reverse_bits)] #[inline] fn reverse_bits(self) -> Self { <$T>::reverse_bits(self) From 8a59e1785696c81301d547e58106e132d9eadee1 Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Wed, 7 Feb 2024 15:58:04 -0800 Subject: [PATCH 04/12] Assume has_leading_trailing_ones --- build.rs | 1 - src/int.rs | 2 -- 2 files changed, 3 deletions(-) diff --git a/build.rs b/build.rs index 205b8576..5101ad39 100644 --- a/build.rs +++ b/build.rs @@ -3,7 +3,6 @@ use std::env; fn main() { let ac = autocfg::new(); - ac.emit_expression_cfg("1u32.trailing_ones()", "has_leading_trailing_ones"); ac.emit_expression_cfg("1u32.div_euclid(1u32)", "has_div_euclid"); if env::var_os("CARGO_FEATURE_STD").is_some() { diff --git a/src/int.rs b/src/int.rs index 7669130e..c6284bf4 100644 --- a/src/int.rs +++ b/src/int.rs @@ -404,7 +404,6 @@ macro_rules! prim_int_impl { <$T>::count_zeros(self) } - #[cfg(has_leading_trailing_ones)] #[inline] fn leading_ones(self) -> u32 { <$T>::leading_ones(self) @@ -415,7 +414,6 @@ macro_rules! prim_int_impl { <$T>::leading_zeros(self) } - #[cfg(has_leading_trailing_ones)] #[inline] fn trailing_ones(self) -> u32 { <$T>::trailing_ones(self) From 84e935b2fbd1a81a831040d0c2610e995a432f1c Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Wed, 7 Feb 2024 16:01:59 -0800 Subject: [PATCH 05/12] Assume has_div_euclid --- build.rs | 2 - src/ops/euclid.rs | 121 +++------------------------------------------- 2 files changed, 7 insertions(+), 116 deletions(-) diff --git a/build.rs b/build.rs index 5101ad39..cdebeaaf 100644 --- a/build.rs +++ b/build.rs @@ -3,8 +3,6 @@ use std::env; fn main() { let ac = autocfg::new(); - ac.emit_expression_cfg("1u32.div_euclid(1u32)", "has_div_euclid"); - if env::var_os("CARGO_FEATURE_STD").is_some() { ac.emit_expression_cfg("1f64.copysign(-1f64)", "has_copysign"); } diff --git a/src/ops/euclid.rs b/src/ops/euclid.rs index c12137db..fa7b317a 100644 --- a/src/ops/euclid.rs +++ b/src/ops/euclid.rs @@ -71,7 +71,6 @@ pub trait Euclid: Sized + Div + Rem { macro_rules! euclid_forward_impl { ($($t:ty)*) => {$( - #[cfg(has_div_euclid)] impl Euclid for $t { #[inline] fn div_euclid(&self, v: &$t) -> Self { @@ -86,64 +85,13 @@ macro_rules! euclid_forward_impl { )*} } -macro_rules! euclid_int_impl { - ($($t:ty)*) => {$( - euclid_forward_impl!($t); - - #[cfg(not(has_div_euclid))] - impl Euclid for $t { - #[inline] - fn div_euclid(&self, v: &$t) -> Self { - let q = self / v; - if self % v < 0 { - return if *v > 0 { q - 1 } else { q + 1 } - } - q - } - - #[inline] - fn rem_euclid(&self, v: &$t) -> Self { - let r = self % v; - if r < 0 { - if *v < 0 { - r - v - } else { - r + v - } - } else { - r - } - } - } - )*} -} +euclid_forward_impl!(isize i8 i16 i32 i64 i128); +euclid_forward_impl!(usize u8 u16 u32 u64 u128); -macro_rules! euclid_uint_impl { - ($($t:ty)*) => {$( - euclid_forward_impl!($t); - - #[cfg(not(has_div_euclid))] - impl Euclid for $t { - #[inline] - fn div_euclid(&self, v: &$t) -> Self { - self / v - } - - #[inline] - fn rem_euclid(&self, v: &$t) -> Self { - self % v - } - } - )*} -} - -euclid_int_impl!(isize i8 i16 i32 i64 i128); -euclid_uint_impl!(usize u8 u16 u32 u64 u128); - -#[cfg(all(has_div_euclid, feature = "std"))] +#[cfg(feature = "std")] euclid_forward_impl!(f32 f64); -#[cfg(not(all(has_div_euclid, feature = "std")))] +#[cfg(not(feature = "std"))] impl Euclid for f32 { #[inline] fn div_euclid(&self, v: &f32) -> f32 { @@ -165,7 +113,7 @@ impl Euclid for f32 { } } -#[cfg(not(all(has_div_euclid, feature = "std")))] +#[cfg(not(feature = "std"))] impl Euclid for f64 { #[inline] fn div_euclid(&self, v: &f64) -> f64 { @@ -219,7 +167,6 @@ pub trait CheckedEuclid: Euclid { macro_rules! checked_euclid_forward_impl { ($($t:ty)*) => {$( - #[cfg(has_div_euclid)] impl CheckedEuclid for $t { #[inline] fn checked_div_euclid(&self, v: &$t) -> Option { @@ -234,62 +181,8 @@ macro_rules! checked_euclid_forward_impl { )*} } -macro_rules! checked_euclid_int_impl { - ($($t:ty)*) => {$( - checked_euclid_forward_impl!($t); - - #[cfg(not(has_div_euclid))] - impl CheckedEuclid for $t { - #[inline] - fn checked_div_euclid(&self, v: &$t) -> Option<$t> { - if *v == 0 || (*self == Self::min_value() && *v == -1) { - None - } else { - Some(Euclid::div_euclid(self, v)) - } - } - - #[inline] - fn checked_rem_euclid(&self, v: &$t) -> Option<$t> { - if *v == 0 || (*self == Self::min_value() && *v == -1) { - None - } else { - Some(Euclid::rem_euclid(self, v)) - } - } - } - )*} -} - -macro_rules! checked_euclid_uint_impl { - ($($t:ty)*) => {$( - checked_euclid_forward_impl!($t); - - #[cfg(not(has_div_euclid))] - impl CheckedEuclid for $t { - #[inline] - fn checked_div_euclid(&self, v: &$t) -> Option<$t> { - if *v == 0 { - None - } else { - Some(Euclid::div_euclid(self, v)) - } - } - - #[inline] - fn checked_rem_euclid(&self, v: &$t) -> Option<$t> { - if *v == 0 { - None - } else { - Some(Euclid::rem_euclid(self, v)) - } - } - } - )*} -} - -checked_euclid_int_impl!(isize i8 i16 i32 i64 i128); -checked_euclid_uint_impl!(usize u8 u16 u32 u64 u128); +checked_euclid_forward_impl!(isize i8 i16 i32 i64 i128); +checked_euclid_forward_impl!(usize u8 u16 u32 u64 u128); #[cfg(test)] mod tests { From 7c2f3bc1adf444b41b87a55368eaeebd136bad65 Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Wed, 7 Feb 2024 16:03:44 -0800 Subject: [PATCH 06/12] Assume has_copysign --- build.rs | 5 ----- src/float.rs | 4 ---- 2 files changed, 9 deletions(-) diff --git a/build.rs b/build.rs index cdebeaaf..41f4397c 100644 --- a/build.rs +++ b/build.rs @@ -1,11 +1,6 @@ -use std::env; - fn main() { let ac = autocfg::new(); - if env::var_os("CARGO_FEATURE_STD").is_some() { - ac.emit_expression_cfg("1f64.copysign(-1f64)", "has_copysign"); - } ac.emit_expression_cfg("1f64.is_subnormal()", "has_is_subnormal"); ac.emit_expression_cfg("1f64.total_cmp(&2f64)", "has_total_cmp"); diff --git a/src/float.rs b/src/float.rs index 844b89ae..cd952263 100644 --- a/src/float.rs +++ b/src/float.rs @@ -1944,10 +1944,6 @@ macro_rules! float_impl_std { Self::asinh(self) -> Self; Self::acosh(self) -> Self; Self::atanh(self) -> Self; - } - - #[cfg(has_copysign)] - forward! { Self::copysign(self, sign: Self) -> Self; } From 33c92deb302f3269409d3722a441293282c2a2ce Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Wed, 7 Feb 2024 16:06:30 -0800 Subject: [PATCH 07/12] Assume has_is_subnormal --- build.rs | 1 - src/float.rs | 24 ++++-------------------- 2 files changed, 4 insertions(+), 21 deletions(-) diff --git a/build.rs b/build.rs index 41f4397c..7091f9c8 100644 --- a/build.rs +++ b/build.rs @@ -1,7 +1,6 @@ fn main() { let ac = autocfg::new(); - ac.emit_expression_cfg("1f64.is_subnormal()", "has_is_subnormal"); ac.emit_expression_cfg("1f64.total_cmp(&2f64)", "has_total_cmp"); ac.emit_expression_cfg("1u32.to_ne_bytes()", "has_int_to_from_bytes"); diff --git a/src/float.rs b/src/float.rs index cd952263..7a42dd87 100644 --- a/src/float.rs +++ b/src/float.rs @@ -790,6 +790,7 @@ impl FloatCore for f32 { Self::is_infinite(self) -> bool; Self::is_finite(self) -> bool; Self::is_normal(self) -> bool; + Self::is_subnormal(self) -> bool; Self::classify(self) -> FpCategory; Self::is_sign_positive(self) -> bool; Self::is_sign_negative(self) -> bool; @@ -800,11 +801,6 @@ impl FloatCore for f32 { Self::to_radians(self) -> Self; } - #[cfg(has_is_subnormal)] - forward! { - Self::is_subnormal(self) -> bool; - } - #[cfg(feature = "std")] forward! { Self::floor(self) -> Self; @@ -855,6 +851,7 @@ impl FloatCore for f64 { Self::is_infinite(self) -> bool; Self::is_finite(self) -> bool; Self::is_normal(self) -> bool; + Self::is_subnormal(self) -> bool; Self::classify(self) -> FpCategory; Self::is_sign_positive(self) -> bool; Self::is_sign_negative(self) -> bool; @@ -865,11 +862,6 @@ impl FloatCore for f64 { Self::to_radians(self) -> Self; } - #[cfg(has_is_subnormal)] - forward! { - Self::is_subnormal(self) -> bool; - } - #[cfg(feature = "std")] forward! { Self::floor(self) -> Self; @@ -1901,6 +1893,7 @@ macro_rules! float_impl_std { Self::is_infinite(self) -> bool; Self::is_finite(self) -> bool; Self::is_normal(self) -> bool; + Self::is_subnormal(self) -> bool; Self::classify(self) -> FpCategory; Self::floor(self) -> Self; Self::ceil(self) -> Self; @@ -1946,11 +1939,6 @@ macro_rules! float_impl_std { Self::atanh(self) -> Self; Self::copysign(self, sign: Self) -> Self; } - - #[cfg(has_is_subnormal)] - forward! { - Self::is_subnormal(self) -> bool; - } } }; } @@ -1989,6 +1977,7 @@ macro_rules! float_impl_libm { Self::is_infinite(self) -> bool; Self::is_finite(self) -> bool; Self::is_normal(self) -> bool; + Self::is_subnormal(self) -> bool; Self::classify(self) -> FpCategory; Self::is_sign_positive(self) -> bool; Self::is_sign_negative(self) -> bool; @@ -1999,11 +1988,6 @@ macro_rules! float_impl_libm { Self::to_radians(self) -> Self; } - #[cfg(has_is_subnormal)] - forward! { - Self::is_subnormal(self) -> bool; - } - forward! { FloatCore::signum(self) -> Self; FloatCore::powi(self, n: i32) -> Self; From 531d965cefc7bfad9566d505b03573fb1a7283a2 Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Wed, 7 Feb 2024 16:09:04 -0800 Subject: [PATCH 08/12] Note the MSRV for total_cmp --- build.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.rs b/build.rs index 7091f9c8..4d0ae26a 100644 --- a/build.rs +++ b/build.rs @@ -1,7 +1,7 @@ fn main() { let ac = autocfg::new(); - ac.emit_expression_cfg("1f64.total_cmp(&2f64)", "has_total_cmp"); + ac.emit_expression_cfg("1f64.total_cmp(&2f64)", "has_total_cmp"); // 1.62 ac.emit_expression_cfg("1u32.to_ne_bytes()", "has_int_to_from_bytes"); ac.emit_expression_cfg("3.14f64.to_ne_bytes()", "has_float_to_from_bytes"); From 7212041f31654953ba55c7bc66e6a8440524dda4 Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Wed, 7 Feb 2024 16:09:15 -0800 Subject: [PATCH 09/12] Assume has_int_to_from_bytes --- build.rs | 1 - src/ops/bytes.rs | 44 -------------------------------------------- 2 files changed, 45 deletions(-) diff --git a/build.rs b/build.rs index 4d0ae26a..32f5f923 100644 --- a/build.rs +++ b/build.rs @@ -3,7 +3,6 @@ fn main() { ac.emit_expression_cfg("1f64.total_cmp(&2f64)", "has_total_cmp"); // 1.62 - ac.emit_expression_cfg("1u32.to_ne_bytes()", "has_int_to_from_bytes"); ac.emit_expression_cfg("3.14f64.to_ne_bytes()", "has_float_to_from_bytes"); autocfg::rerun_path("build.rs"); diff --git a/src/ops/bytes.rs b/src/ops/bytes.rs index 4df9ecd0..1351aa66 100644 --- a/src/ops/bytes.rs +++ b/src/ops/bytes.rs @@ -2,8 +2,6 @@ use core::borrow::{Borrow, BorrowMut}; use core::cmp::{Eq, Ord, PartialEq, PartialOrd}; use core::fmt::Debug; use core::hash::Hash; -#[cfg(not(has_int_to_from_bytes))] -use core::mem::transmute; pub trait NumBytes: Debug @@ -236,7 +234,6 @@ macro_rules! float_to_from_bytes_impl { macro_rules! int_to_from_bytes_impl { ($T:ty, $L:expr) => { - #[cfg(has_int_to_from_bytes)] impl ToBytes for $T { type Bytes = [u8; $L]; @@ -256,7 +253,6 @@ macro_rules! int_to_from_bytes_impl { } } - #[cfg(has_int_to_from_bytes)] impl FromBytes for $T { type Bytes = [u8; $L]; @@ -275,46 +271,6 @@ macro_rules! int_to_from_bytes_impl { <$T>::from_ne_bytes(*bytes) } } - - #[cfg(not(has_int_to_from_bytes))] - impl ToBytes for $T { - type Bytes = [u8; $L]; - - #[inline] - fn to_be_bytes(&self) -> Self::Bytes { - <$T as ToBytes>::to_ne_bytes(&<$T>::to_be(*self)) - } - - #[inline] - fn to_le_bytes(&self) -> Self::Bytes { - <$T as ToBytes>::to_ne_bytes(&<$T>::to_le(*self)) - } - - #[inline] - fn to_ne_bytes(&self) -> Self::Bytes { - unsafe { transmute(*self) } - } - } - - #[cfg(not(has_int_to_from_bytes))] - impl FromBytes for $T { - type Bytes = [u8; $L]; - - #[inline] - fn from_be_bytes(bytes: &Self::Bytes) -> Self { - Self::from_be(::from_ne_bytes(bytes)) - } - - #[inline] - fn from_le_bytes(bytes: &Self::Bytes) -> Self { - Self::from_le(::from_ne_bytes(bytes)) - } - - #[inline] - fn from_ne_bytes(bytes: &Self::Bytes) -> Self { - unsafe { transmute(*bytes) } - } - } }; } From 4e253cdaa9948f4fb8b4136c78d655a34eac3c26 Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Wed, 7 Feb 2024 16:10:06 -0800 Subject: [PATCH 10/12] Assume has_float_to_from_bytes --- build.rs | 2 -- src/ops/bytes.rs | 42 ------------------------------------------ 2 files changed, 44 deletions(-) diff --git a/build.rs b/build.rs index 32f5f923..98b06bef 100644 --- a/build.rs +++ b/build.rs @@ -3,7 +3,5 @@ fn main() { ac.emit_expression_cfg("1f64.total_cmp(&2f64)", "has_total_cmp"); // 1.62 - ac.emit_expression_cfg("3.14f64.to_ne_bytes()", "has_float_to_from_bytes"); - autocfg::rerun_path("build.rs"); } diff --git a/src/ops/bytes.rs b/src/ops/bytes.rs index 1351aa66..f6a8030a 100644 --- a/src/ops/bytes.rs +++ b/src/ops/bytes.rs @@ -150,7 +150,6 @@ pub trait FromBytes: Sized { macro_rules! float_to_from_bytes_impl { ($T:ty, $L:expr) => { - #[cfg(has_float_to_from_bytes)] impl ToBytes for $T { type Bytes = [u8; $L]; @@ -170,7 +169,6 @@ macro_rules! float_to_from_bytes_impl { } } - #[cfg(has_float_to_from_bytes)] impl FromBytes for $T { type Bytes = [u8; $L]; @@ -189,46 +187,6 @@ macro_rules! float_to_from_bytes_impl { <$T>::from_ne_bytes(*bytes) } } - - #[cfg(not(has_float_to_from_bytes))] - impl ToBytes for $T { - type Bytes = [u8; $L]; - - #[inline] - fn to_be_bytes(&self) -> Self::Bytes { - ToBytes::to_be_bytes(&self.to_bits()) - } - - #[inline] - fn to_le_bytes(&self) -> Self::Bytes { - ToBytes::to_le_bytes(&self.to_bits()) - } - - #[inline] - fn to_ne_bytes(&self) -> Self::Bytes { - ToBytes::to_ne_bytes(&self.to_bits()) - } - } - - #[cfg(not(has_float_to_from_bytes))] - impl FromBytes for $T { - type Bytes = [u8; $L]; - - #[inline] - fn from_be_bytes(bytes: &Self::Bytes) -> Self { - Self::from_bits(FromBytes::from_be_bytes(bytes)) - } - - #[inline] - fn from_le_bytes(bytes: &Self::Bytes) -> Self { - Self::from_bits(FromBytes::from_le_bytes(bytes)) - } - - #[inline] - fn from_ne_bytes(bytes: &Self::Bytes) -> Self { - Self::from_bits(FromBytes::from_ne_bytes(bytes)) - } - } }; } From e9bea92808de77ff4d4e94c8fe0dccece542d2ce Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Wed, 7 Feb 2024 16:13:31 -0800 Subject: [PATCH 11/12] Upgrade to 2021 edition --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 3abe8754..b75a7e1a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,7 +12,7 @@ version = "0.2.18" readme = "README.md" build = "build.rs" exclude = ["/ci/*", "/.github/*"] -edition = "2018" +edition = "2021" rust-version = "1.60" [package.metadata.docs.rs] From ca42b4e106486b8fe9b22eeabb90aa8a0452f148 Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Wed, 7 Feb 2024 17:05:25 -0800 Subject: [PATCH 12/12] Update the MSRV in docs --- README.md | 4 ++-- src/lib.rs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index fa2f297c..71464a86 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ [![crate](https://img.shields.io/crates/v/num-traits.svg)](https://crates.io/crates/num-traits) [![documentation](https://docs.rs/num-traits/badge.svg)](https://docs.rs/num-traits) -[![minimum rustc 1.31](https://img.shields.io/badge/rustc-1.31+-red.svg)](https://rust-lang.github.io/rfcs/2495-min-rust-version.html) +[![minimum rustc 1.60](https://img.shields.io/badge/rustc-1.60+-red.svg)](https://rust-lang.github.io/rfcs/2495-min-rust-version.html) [![build status](https://github.com/rust-num/num-traits/workflows/master/badge.svg)](https://github.com/rust-num/num-traits/actions) Numeric traits for generic mathematics in Rust. @@ -40,7 +40,7 @@ Release notes are available in [RELEASES.md](RELEASES.md). ## Compatibility -The `num-traits` crate is tested for rustc 1.31 and greater. +The `num-traits` crate is tested for rustc 1.60 and greater. ## License diff --git a/src/lib.rs b/src/lib.rs index 9ee16fc8..d392e920 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -12,7 +12,7 @@ //! //! ## Compatibility //! -//! The `num-traits` crate is tested for rustc 1.31 and greater. +//! The `num-traits` crate is tested for rustc 1.60 and greater. #![doc(html_root_url = "https://docs.rs/num-traits/0.2")] #![deny(unconditional_recursion)]