Skip to content

Commit

Permalink
fix a potential panic issue
Browse files Browse the repository at this point in the history
magiclen committed Nov 26, 2023
1 parent 2a9883a commit c029a4d
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/bit/built_in_traits.rs
Original file line number Diff line number Diff line change
@@ -45,7 +45,7 @@ impl From<usize> for Bit {
fn from(value: usize) -> Self {
#[cfg(target_pointer_width = "128")]
{
Bit::from_u128(value as u128).unwrap()
Byte::from_u128(value as u128).unwrap_or(Byte::MAX)
}

#[cfg(not(target_pointer_width = "128"))]
2 changes: 1 addition & 1 deletion src/byte/built_in_traits.rs
Original file line number Diff line number Diff line change
@@ -45,7 +45,7 @@ impl From<usize> for Byte {
fn from(value: usize) -> Self {
#[cfg(target_pointer_width = "128")]
{
Byte::from_u128(value as u128).unwrap()
Byte::from_u128(value as u128).unwrap_or(Byte::MAX)
}

#[cfg(not(target_pointer_width = "128"))]

0 comments on commit c029a4d

Please sign in to comment.