Skip to content
This repository has been archived by the owner on Aug 21, 2024. It is now read-only.

Commit

Permalink
fix(fee): fix doc of usize u128 conversions (#1446)
Browse files Browse the repository at this point in the history
  • Loading branch information
noaov1 authored Feb 6, 2024
1 parent 57ae121 commit a5e902e
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions crates/blockifier/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@ pub const fn const_max(a: u128, b: u128) -> u128 {
[a, b][(a < b) as usize]
}

/// Conversion from usize to u128. Currently, usize has 64 bits, so this conversion should never
/// fail.
/// Conversion from u128 to usize. This conversion should only be used if the value came from a
/// usize.
pub fn usize_from_u128(val: u128) -> Result<usize, NumericConversionError> {
val.try_into().map_err(|_| NumericConversionError::U128ToUsizeError(val))
}

/// Conversion from u128 to usize. This conversion should only be used if the value came from a
/// usize.
/// Conversion from usize to u128. May fail on architectures with over 128 bits
/// of address space.
pub fn u128_from_usize(val: usize) -> Result<u128, NumericConversionError> {
val.try_into().map_err(|_| NumericConversionError::UsizeToU128Error(val))
}

0 comments on commit a5e902e

Please sign in to comment.