From 7212041f31654953ba55c7bc66e6a8440524dda4 Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Wed, 7 Feb 2024 16:09:15 -0800 Subject: [PATCH] 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) } - } - } }; }