pub trait IntoBytes<const T: usize> {
// Required methods
fn into_le_bytes(self) -> [u8; T];
fn into_be_bytes(self) -> [u8; T];
}
Expand description
Defines a type can be converted into a byte array.
use num_bytes::IntoBytes;
let a = 8u32;
let b = a.into_le_bytes();
assert_eq!(b,[8,0,0,0]);