Skip to content

Commit 313505f

Browse files
authored
Add a const fn version of Uint::to_le_bytes (#555)
Previously only `Uint::to_be_bytes` was defined this way.
1 parent a663070 commit 313505f

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

src/uint/macros.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,11 @@ macro_rules! impl_uint_aliases {
4040
pub const fn to_be_bytes(&self) -> [u8; $bits / 8] {
4141
encoding::uint_to_be_bytes::<{ nlimbs!($bits) }, { $bits / 8 }>(self)
4242
}
43+
44+
/// Serialize as little endian bytes.
45+
pub const fn to_le_bytes(&self) -> [u8; $bits / 8] {
46+
encoding::uint_to_le_bytes::<{ nlimbs!($bits) }, { $bits / 8 }>(self)
47+
}
4348
}
4449

4550
impl Encoding for $name {

0 commit comments

Comments
 (0)