Skip to content

Commit 7212041

Browse files
committed
Assume has_int_to_from_bytes
1 parent 531d965 commit 7212041

File tree

2 files changed

+0
-45
lines changed

2 files changed

+0
-45
lines changed

build.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ fn main() {
33

44
ac.emit_expression_cfg("1f64.total_cmp(&2f64)", "has_total_cmp"); // 1.62
55

6-
ac.emit_expression_cfg("1u32.to_ne_bytes()", "has_int_to_from_bytes");
76
ac.emit_expression_cfg("3.14f64.to_ne_bytes()", "has_float_to_from_bytes");
87

98
autocfg::rerun_path("build.rs");

src/ops/bytes.rs

Lines changed: 0 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@ use core::borrow::{Borrow, BorrowMut};
22
use core::cmp::{Eq, Ord, PartialEq, PartialOrd};
33
use core::fmt::Debug;
44
use core::hash::Hash;
5-
#[cfg(not(has_int_to_from_bytes))]
6-
use core::mem::transmute;
75

86
pub trait NumBytes:
97
Debug
@@ -236,7 +234,6 @@ macro_rules! float_to_from_bytes_impl {
236234

237235
macro_rules! int_to_from_bytes_impl {
238236
($T:ty, $L:expr) => {
239-
#[cfg(has_int_to_from_bytes)]
240237
impl ToBytes for $T {
241238
type Bytes = [u8; $L];
242239

@@ -256,7 +253,6 @@ macro_rules! int_to_from_bytes_impl {
256253
}
257254
}
258255

259-
#[cfg(has_int_to_from_bytes)]
260256
impl FromBytes for $T {
261257
type Bytes = [u8; $L];
262258

@@ -275,46 +271,6 @@ macro_rules! int_to_from_bytes_impl {
275271
<$T>::from_ne_bytes(*bytes)
276272
}
277273
}
278-
279-
#[cfg(not(has_int_to_from_bytes))]
280-
impl ToBytes for $T {
281-
type Bytes = [u8; $L];
282-
283-
#[inline]
284-
fn to_be_bytes(&self) -> Self::Bytes {
285-
<$T as ToBytes>::to_ne_bytes(&<$T>::to_be(*self))
286-
}
287-
288-
#[inline]
289-
fn to_le_bytes(&self) -> Self::Bytes {
290-
<$T as ToBytes>::to_ne_bytes(&<$T>::to_le(*self))
291-
}
292-
293-
#[inline]
294-
fn to_ne_bytes(&self) -> Self::Bytes {
295-
unsafe { transmute(*self) }
296-
}
297-
}
298-
299-
#[cfg(not(has_int_to_from_bytes))]
300-
impl FromBytes for $T {
301-
type Bytes = [u8; $L];
302-
303-
#[inline]
304-
fn from_be_bytes(bytes: &Self::Bytes) -> Self {
305-
Self::from_be(<Self as FromBytes>::from_ne_bytes(bytes))
306-
}
307-
308-
#[inline]
309-
fn from_le_bytes(bytes: &Self::Bytes) -> Self {
310-
Self::from_le(<Self as FromBytes>::from_ne_bytes(bytes))
311-
}
312-
313-
#[inline]
314-
fn from_ne_bytes(bytes: &Self::Bytes) -> Self {
315-
unsafe { transmute(*bytes) }
316-
}
317-
}
318274
};
319275
}
320276

0 commit comments

Comments
 (0)