@@ -9,13 +9,15 @@ macro_rules! impl_to_bytes {
9
9
{
10
10
/// Return the memory representation of this integer as a byte array in native byte
11
11
/// order.
12
+ #[ inline]
12
13
pub fn to_ne_bytes( self ) -> crate :: simd:: Simd <u8 , { { $size * LANES } } > {
13
14
// Safety: transmuting between vectors is safe
14
15
unsafe { core:: mem:: transmute_copy( & self ) }
15
16
}
16
17
17
18
/// Return the memory representation of this integer as a byte array in big-endian
18
19
/// (network) byte order.
20
+ #[ inline]
19
21
pub fn to_be_bytes( self ) -> crate :: simd:: Simd <u8 , { { $size * LANES } } > {
20
22
let bytes = self . to_ne_bytes( ) ;
21
23
if cfg!( target_endian = "big" ) {
@@ -27,6 +29,7 @@ macro_rules! impl_to_bytes {
27
29
28
30
/// Return the memory representation of this integer as a byte array in little-endian
29
31
/// byte order.
32
+ #[ inline]
30
33
pub fn to_le_bytes( self ) -> crate :: simd:: Simd <u8 , { { $size * LANES } } > {
31
34
let bytes = self . to_ne_bytes( ) ;
32
35
if cfg!( target_endian = "little" ) {
@@ -38,12 +41,14 @@ macro_rules! impl_to_bytes {
38
41
39
42
/// Create a native endian integer value from its memory representation as a byte array
40
43
/// in native endianness.
44
+ #[ inline]
41
45
pub fn from_ne_bytes( bytes: crate :: simd:: Simd <u8 , { { $size * LANES } } >) -> Self {
42
46
// Safety: transmuting between vectors is safe
43
47
unsafe { core:: mem:: transmute_copy( & bytes) }
44
48
}
45
49
46
50
/// Create an integer value from its representation as a byte array in big endian.
51
+ #[ inline]
47
52
pub fn from_be_bytes( bytes: crate :: simd:: Simd <u8 , { { $size * LANES } } >) -> Self {
48
53
let bytes = if cfg!( target_endian = "big" ) {
49
54
bytes
@@ -54,6 +59,7 @@ macro_rules! impl_to_bytes {
54
59
}
55
60
56
61
/// Create an integer value from its representation as a byte array in little endian.
62
+ #[ inline]
57
63
pub fn from_le_bytes( bytes: crate :: simd:: Simd <u8 , { { $size * LANES } } >) -> Self {
58
64
let bytes = if cfg!( target_endian = "little" ) {
59
65
bytes
0 commit comments