|
|
|
@@ -1921,12 +1921,10 @@ big-endian (network) byte order.
|
|
|
|
# Examples
|
|
|
|
# Examples
|
|
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
```
|
|
|
|
#![feature(int_to_from_bytes)]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let bytes = ", $swap_op, stringify!($SelfT), ".to_be_bytes();
|
|
|
|
let bytes = ", $swap_op, stringify!($SelfT), ".to_be_bytes();
|
|
|
|
assert_eq!(bytes, ", $be_bytes, ");
|
|
|
|
assert_eq!(bytes, ", $be_bytes, ");
|
|
|
|
```"),
|
|
|
|
```"),
|
|
|
|
#[unstable(feature = "int_to_from_bytes", issue = "52963")]
|
|
|
|
#[stable(feature = "int_to_from_bytes", since = "1.32.0")]
|
|
|
|
#[rustc_const_unstable(feature = "const_int_conversion")]
|
|
|
|
#[rustc_const_unstable(feature = "const_int_conversion")]
|
|
|
|
#[inline]
|
|
|
|
#[inline]
|
|
|
|
pub const fn to_be_bytes(self) -> [u8; mem::size_of::<Self>()] {
|
|
|
|
pub const fn to_be_bytes(self) -> [u8; mem::size_of::<Self>()] {
|
|
|
|
@@ -1941,12 +1939,10 @@ little-endian byte order.
|
|
|
|
# Examples
|
|
|
|
# Examples
|
|
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
```
|
|
|
|
#![feature(int_to_from_bytes)]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let bytes = ", $swap_op, stringify!($SelfT), ".to_le_bytes();
|
|
|
|
let bytes = ", $swap_op, stringify!($SelfT), ".to_le_bytes();
|
|
|
|
assert_eq!(bytes, ", $le_bytes, ");
|
|
|
|
assert_eq!(bytes, ", $le_bytes, ");
|
|
|
|
```"),
|
|
|
|
```"),
|
|
|
|
#[unstable(feature = "int_to_from_bytes", issue = "52963")]
|
|
|
|
#[stable(feature = "int_to_from_bytes", since = "1.32.0")]
|
|
|
|
#[rustc_const_unstable(feature = "const_int_conversion")]
|
|
|
|
#[rustc_const_unstable(feature = "const_int_conversion")]
|
|
|
|
#[inline]
|
|
|
|
#[inline]
|
|
|
|
pub const fn to_le_bytes(self) -> [u8; mem::size_of::<Self>()] {
|
|
|
|
pub const fn to_le_bytes(self) -> [u8; mem::size_of::<Self>()] {
|
|
|
|
@@ -1969,8 +1965,6 @@ instead.
|
|
|
|
# Examples
|
|
|
|
# Examples
|
|
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
```
|
|
|
|
#![feature(int_to_from_bytes)]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let bytes = ", $swap_op, stringify!($SelfT), ".to_ne_bytes();
|
|
|
|
let bytes = ", $swap_op, stringify!($SelfT), ".to_ne_bytes();
|
|
|
|
assert_eq!(bytes, if cfg!(target_endian = \"big\") {
|
|
|
|
assert_eq!(bytes, if cfg!(target_endian = \"big\") {
|
|
|
|
", $be_bytes, "
|
|
|
|
", $be_bytes, "
|
|
|
|
@@ -1978,7 +1972,7 @@ assert_eq!(bytes, if cfg!(target_endian = \"big\") {
|
|
|
|
", $le_bytes, "
|
|
|
|
", $le_bytes, "
|
|
|
|
});
|
|
|
|
});
|
|
|
|
```"),
|
|
|
|
```"),
|
|
|
|
#[unstable(feature = "int_to_from_bytes", issue = "52963")]
|
|
|
|
#[stable(feature = "int_to_from_bytes", since = "1.32.0")]
|
|
|
|
#[rustc_const_unstable(feature = "const_int_conversion")]
|
|
|
|
#[rustc_const_unstable(feature = "const_int_conversion")]
|
|
|
|
#[inline]
|
|
|
|
#[inline]
|
|
|
|
pub const fn to_ne_bytes(self) -> [u8; mem::size_of::<Self>()] {
|
|
|
|
pub const fn to_ne_bytes(self) -> [u8; mem::size_of::<Self>()] {
|
|
|
|
@@ -1993,12 +1987,10 @@ big endian.
|
|
|
|
# Examples
|
|
|
|
# Examples
|
|
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
```
|
|
|
|
#![feature(int_to_from_bytes)]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let value = ", stringify!($SelfT), "::from_be_bytes(", $be_bytes, ");
|
|
|
|
let value = ", stringify!($SelfT), "::from_be_bytes(", $be_bytes, ");
|
|
|
|
assert_eq!(value, ", $swap_op, ");
|
|
|
|
assert_eq!(value, ", $swap_op, ");
|
|
|
|
```"),
|
|
|
|
```"),
|
|
|
|
#[unstable(feature = "int_to_from_bytes", issue = "52963")]
|
|
|
|
#[stable(feature = "int_to_from_bytes", since = "1.32.0")]
|
|
|
|
#[rustc_const_unstable(feature = "const_int_conversion")]
|
|
|
|
#[rustc_const_unstable(feature = "const_int_conversion")]
|
|
|
|
#[inline]
|
|
|
|
#[inline]
|
|
|
|
pub const fn from_be_bytes(bytes: [u8; mem::size_of::<Self>()]) -> Self {
|
|
|
|
pub const fn from_be_bytes(bytes: [u8; mem::size_of::<Self>()]) -> Self {
|
|
|
|
@@ -2014,12 +2006,10 @@ little endian.
|
|
|
|
# Examples
|
|
|
|
# Examples
|
|
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
```
|
|
|
|
#![feature(int_to_from_bytes)]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let value = ", stringify!($SelfT), "::from_le_bytes(", $le_bytes, ");
|
|
|
|
let value = ", stringify!($SelfT), "::from_le_bytes(", $le_bytes, ");
|
|
|
|
assert_eq!(value, ", $swap_op, ");
|
|
|
|
assert_eq!(value, ", $swap_op, ");
|
|
|
|
```"),
|
|
|
|
```"),
|
|
|
|
#[unstable(feature = "int_to_from_bytes", issue = "52963")]
|
|
|
|
#[stable(feature = "int_to_from_bytes", since = "1.32.0")]
|
|
|
|
#[rustc_const_unstable(feature = "const_int_conversion")]
|
|
|
|
#[rustc_const_unstable(feature = "const_int_conversion")]
|
|
|
|
#[inline]
|
|
|
|
#[inline]
|
|
|
|
pub const fn from_le_bytes(bytes: [u8; mem::size_of::<Self>()]) -> Self {
|
|
|
|
pub const fn from_le_bytes(bytes: [u8; mem::size_of::<Self>()]) -> Self {
|
|
|
|
@@ -2041,8 +2031,6 @@ appropriate instead.
|
|
|
|
# Examples
|
|
|
|
# Examples
|
|
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
```
|
|
|
|
#![feature(int_to_from_bytes)]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let value = ", stringify!($SelfT), "::from_ne_bytes(if cfg!(target_endian = \"big\") {
|
|
|
|
let value = ", stringify!($SelfT), "::from_ne_bytes(if cfg!(target_endian = \"big\") {
|
|
|
|
", $be_bytes, "
|
|
|
|
", $be_bytes, "
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
@@ -2050,7 +2038,7 @@ let value = ", stringify!($SelfT), "::from_ne_bytes(if cfg!(target_endian = \"bi
|
|
|
|
});
|
|
|
|
});
|
|
|
|
assert_eq!(value, ", $swap_op, ");
|
|
|
|
assert_eq!(value, ", $swap_op, ");
|
|
|
|
```"),
|
|
|
|
```"),
|
|
|
|
#[unstable(feature = "int_to_from_bytes", issue = "52963")]
|
|
|
|
#[stable(feature = "int_to_from_bytes", since = "1.32.0")]
|
|
|
|
#[rustc_const_unstable(feature = "const_int_conversion")]
|
|
|
|
#[rustc_const_unstable(feature = "const_int_conversion")]
|
|
|
|
#[inline]
|
|
|
|
#[inline]
|
|
|
|
pub const fn from_ne_bytes(bytes: [u8; mem::size_of::<Self>()]) -> Self {
|
|
|
|
pub const fn from_ne_bytes(bytes: [u8; mem::size_of::<Self>()]) -> Self {
|
|
|
|
@@ -3663,12 +3651,10 @@ big-endian (network) byte order.
|
|
|
|
# Examples
|
|
|
|
# Examples
|
|
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
```
|
|
|
|
#![feature(int_to_from_bytes)]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let bytes = ", $swap_op, stringify!($SelfT), ".to_be_bytes();
|
|
|
|
let bytes = ", $swap_op, stringify!($SelfT), ".to_be_bytes();
|
|
|
|
assert_eq!(bytes, ", $be_bytes, ");
|
|
|
|
assert_eq!(bytes, ", $be_bytes, ");
|
|
|
|
```"),
|
|
|
|
```"),
|
|
|
|
#[unstable(feature = "int_to_from_bytes", issue = "52963")]
|
|
|
|
#[stable(feature = "int_to_from_bytes", since = "1.32.0")]
|
|
|
|
#[rustc_const_unstable(feature = "const_int_conversion")]
|
|
|
|
#[rustc_const_unstable(feature = "const_int_conversion")]
|
|
|
|
#[inline]
|
|
|
|
#[inline]
|
|
|
|
pub const fn to_be_bytes(self) -> [u8; mem::size_of::<Self>()] {
|
|
|
|
pub const fn to_be_bytes(self) -> [u8; mem::size_of::<Self>()] {
|
|
|
|
@@ -3683,12 +3669,10 @@ little-endian byte order.
|
|
|
|
# Examples
|
|
|
|
# Examples
|
|
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
```
|
|
|
|
#![feature(int_to_from_bytes)]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let bytes = ", $swap_op, stringify!($SelfT), ".to_le_bytes();
|
|
|
|
let bytes = ", $swap_op, stringify!($SelfT), ".to_le_bytes();
|
|
|
|
assert_eq!(bytes, ", $le_bytes, ");
|
|
|
|
assert_eq!(bytes, ", $le_bytes, ");
|
|
|
|
```"),
|
|
|
|
```"),
|
|
|
|
#[unstable(feature = "int_to_from_bytes", issue = "52963")]
|
|
|
|
#[stable(feature = "int_to_from_bytes", since = "1.32.0")]
|
|
|
|
#[rustc_const_unstable(feature = "const_int_conversion")]
|
|
|
|
#[rustc_const_unstable(feature = "const_int_conversion")]
|
|
|
|
#[inline]
|
|
|
|
#[inline]
|
|
|
|
pub const fn to_le_bytes(self) -> [u8; mem::size_of::<Self>()] {
|
|
|
|
pub const fn to_le_bytes(self) -> [u8; mem::size_of::<Self>()] {
|
|
|
|
@@ -3711,8 +3695,6 @@ instead.
|
|
|
|
# Examples
|
|
|
|
# Examples
|
|
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
```
|
|
|
|
#![feature(int_to_from_bytes)]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let bytes = ", $swap_op, stringify!($SelfT), ".to_ne_bytes();
|
|
|
|
let bytes = ", $swap_op, stringify!($SelfT), ".to_ne_bytes();
|
|
|
|
assert_eq!(bytes, if cfg!(target_endian = \"big\") {
|
|
|
|
assert_eq!(bytes, if cfg!(target_endian = \"big\") {
|
|
|
|
", $be_bytes, "
|
|
|
|
", $be_bytes, "
|
|
|
|
@@ -3720,7 +3702,7 @@ assert_eq!(bytes, if cfg!(target_endian = \"big\") {
|
|
|
|
", $le_bytes, "
|
|
|
|
", $le_bytes, "
|
|
|
|
});
|
|
|
|
});
|
|
|
|
```"),
|
|
|
|
```"),
|
|
|
|
#[unstable(feature = "int_to_from_bytes", issue = "52963")]
|
|
|
|
#[stable(feature = "int_to_from_bytes", since = "1.32.0")]
|
|
|
|
#[rustc_const_unstable(feature = "const_int_conversion")]
|
|
|
|
#[rustc_const_unstable(feature = "const_int_conversion")]
|
|
|
|
#[inline]
|
|
|
|
#[inline]
|
|
|
|
pub const fn to_ne_bytes(self) -> [u8; mem::size_of::<Self>()] {
|
|
|
|
pub const fn to_ne_bytes(self) -> [u8; mem::size_of::<Self>()] {
|
|
|
|
@@ -3735,12 +3717,10 @@ big endian.
|
|
|
|
# Examples
|
|
|
|
# Examples
|
|
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
```
|
|
|
|
#![feature(int_to_from_bytes)]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let value = ", stringify!($SelfT), "::from_be_bytes(", $be_bytes, ");
|
|
|
|
let value = ", stringify!($SelfT), "::from_be_bytes(", $be_bytes, ");
|
|
|
|
assert_eq!(value, ", $swap_op, ");
|
|
|
|
assert_eq!(value, ", $swap_op, ");
|
|
|
|
```"),
|
|
|
|
```"),
|
|
|
|
#[unstable(feature = "int_to_from_bytes", issue = "52963")]
|
|
|
|
#[stable(feature = "int_to_from_bytes", since = "1.32.0")]
|
|
|
|
#[rustc_const_unstable(feature = "const_int_conversion")]
|
|
|
|
#[rustc_const_unstable(feature = "const_int_conversion")]
|
|
|
|
#[inline]
|
|
|
|
#[inline]
|
|
|
|
pub const fn from_be_bytes(bytes: [u8; mem::size_of::<Self>()]) -> Self {
|
|
|
|
pub const fn from_be_bytes(bytes: [u8; mem::size_of::<Self>()]) -> Self {
|
|
|
|
@@ -3756,12 +3736,10 @@ little endian.
|
|
|
|
# Examples
|
|
|
|
# Examples
|
|
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
```
|
|
|
|
#![feature(int_to_from_bytes)]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let value = ", stringify!($SelfT), "::from_le_bytes(", $le_bytes, ");
|
|
|
|
let value = ", stringify!($SelfT), "::from_le_bytes(", $le_bytes, ");
|
|
|
|
assert_eq!(value, ", $swap_op, ");
|
|
|
|
assert_eq!(value, ", $swap_op, ");
|
|
|
|
```"),
|
|
|
|
```"),
|
|
|
|
#[unstable(feature = "int_to_from_bytes", issue = "52963")]
|
|
|
|
#[stable(feature = "int_to_from_bytes", since = "1.32.0")]
|
|
|
|
#[rustc_const_unstable(feature = "const_int_conversion")]
|
|
|
|
#[rustc_const_unstable(feature = "const_int_conversion")]
|
|
|
|
#[inline]
|
|
|
|
#[inline]
|
|
|
|
pub const fn from_le_bytes(bytes: [u8; mem::size_of::<Self>()]) -> Self {
|
|
|
|
pub const fn from_le_bytes(bytes: [u8; mem::size_of::<Self>()]) -> Self {
|
|
|
|
@@ -3783,8 +3761,6 @@ appropriate instead.
|
|
|
|
# Examples
|
|
|
|
# Examples
|
|
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
```
|
|
|
|
#![feature(int_to_from_bytes)]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let value = ", stringify!($SelfT), "::from_ne_bytes(if cfg!(target_endian = \"big\") {
|
|
|
|
let value = ", stringify!($SelfT), "::from_ne_bytes(if cfg!(target_endian = \"big\") {
|
|
|
|
", $be_bytes, "
|
|
|
|
", $be_bytes, "
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
@@ -3792,7 +3768,7 @@ let value = ", stringify!($SelfT), "::from_ne_bytes(if cfg!(target_endian = \"bi
|
|
|
|
});
|
|
|
|
});
|
|
|
|
assert_eq!(value, ", $swap_op, ");
|
|
|
|
assert_eq!(value, ", $swap_op, ");
|
|
|
|
```"),
|
|
|
|
```"),
|
|
|
|
#[unstable(feature = "int_to_from_bytes", issue = "52963")]
|
|
|
|
#[stable(feature = "int_to_from_bytes", since = "1.32.0")]
|
|
|
|
#[rustc_const_unstable(feature = "const_int_conversion")]
|
|
|
|
#[rustc_const_unstable(feature = "const_int_conversion")]
|
|
|
|
#[inline]
|
|
|
|
#[inline]
|
|
|
|
pub const fn from_ne_bytes(bytes: [u8; mem::size_of::<Self>()]) -> Self {
|
|
|
|
pub const fn from_ne_bytes(bytes: [u8; mem::size_of::<Self>()]) -> Self {
|
|
|
|
|