Skip to content

Commit cc36e6f

Browse files
committed
chore: add u32_to_usize
Add yet another function to convert numbers Signed-off-by: Egor Lazarchuk <[email protected]>
1 parent 6d6caf4 commit cc36e6f

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/utils/src/lib.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,15 @@ pub fn get_page_size() -> Result<usize, errno::Error> {
3232
}
3333
}
3434

35+
/// Safely converts a u32 value to a usize value.
36+
/// This bypasses the Clippy lint check because we only support 64-bit platforms.
37+
#[cfg(target_pointer_width = "64")]
38+
#[inline]
39+
#[allow(clippy::cast_possible_truncation)]
40+
pub const fn u32_to_usize(num: u32) -> usize {
41+
num as usize
42+
}
43+
3544
/// Safely converts a u64 value to a usize value.
3645
/// This bypasses the Clippy lint check because we only support 64-bit platforms.
3746
#[cfg(target_pointer_width = "64")]

0 commit comments

Comments
 (0)