-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: Remove
FIXME
s, add utils/uint.rs
- Loading branch information
Showing
7 changed files
with
43 additions
and
78 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/// Utility function for converting u64s into u32 pairs. | ||
pub fn u64_to_le_u32s(n: u64) -> [u32; 2] { | ||
let n = n.to_le_bytes(); | ||
[ | ||
u32::from_le_bytes(n[..4].try_into().unwrap()), | ||
u32::from_le_bytes(n[4..].try_into().unwrap()), | ||
] | ||
} | ||
|
||
/// Utility function for converting a u32 LE pair into a u64. | ||
pub fn u32_pair_to_u64(lo_word: u32, hi_word: u32) -> u64 { | ||
u64::from_le_bytes( | ||
lo_word | ||
.to_le_bytes() | ||
.into_iter() | ||
.chain(hi_word.to_le_bytes()) | ||
.collect::<Vec<_>>() | ||
.try_into() | ||
.unwrap(), | ||
) | ||
} |