@@ -2,8 +2,6 @@ use core::borrow::{Borrow, BorrowMut};
22use core:: cmp:: { Eq , Ord , PartialEq , PartialOrd } ;
33use core:: fmt:: Debug ;
44use core:: hash:: Hash ;
5- #[ cfg( not( has_int_to_from_bytes) ) ]
6- use core:: mem:: transmute;
75
86pub trait NumBytes :
97 Debug
@@ -236,7 +234,6 @@ macro_rules! float_to_from_bytes_impl {
236234
237235macro_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