@@ -2,8 +2,6 @@ use core::borrow::{Borrow, BorrowMut};
2
2
use core:: cmp:: { Eq , Ord , PartialEq , PartialOrd } ;
3
3
use core:: fmt:: Debug ;
4
4
use core:: hash:: Hash ;
5
- #[ cfg( not( has_int_to_from_bytes) ) ]
6
- use core:: mem:: transmute;
7
5
8
6
pub trait NumBytes :
9
7
Debug
@@ -236,7 +234,6 @@ macro_rules! float_to_from_bytes_impl {
236
234
237
235
macro_rules! int_to_from_bytes_impl {
238
236
( $T: ty, $L: expr) => {
239
- #[ cfg( has_int_to_from_bytes) ]
240
237
impl ToBytes for $T {
241
238
type Bytes = [ u8 ; $L] ;
242
239
@@ -256,7 +253,6 @@ macro_rules! int_to_from_bytes_impl {
256
253
}
257
254
}
258
255
259
- #[ cfg( has_int_to_from_bytes) ]
260
256
impl FromBytes for $T {
261
257
type Bytes = [ u8 ; $L] ;
262
258
@@ -275,46 +271,6 @@ macro_rules! int_to_from_bytes_impl {
275
271
<$T>:: from_ne_bytes( * bytes)
276
272
}
277
273
}
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
- }
318
274
} ;
319
275
}
320
276
0 commit comments