Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions src/core/size_value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,7 @@ impl SizeValue {
pub const fn mul(self, rhs: u64) -> Self {
match self.get().checked_mul(rhs) {
None => panic!("Overflow occurred while multiplying size values!"),
Some(val) => {
// SAFETY: This is safe since we checked for overflow
Self(unsafe { NonZeroU64::new_unchecked(val) })
}
Some(val) => Self::new(val),
}
}
}
Expand Down Expand Up @@ -64,6 +61,12 @@ mod test {
SizeValue::new(8).mul(u64::MAX);
}

#[test]
#[should_panic]
fn mul_zero_panic() {
SizeValue::new(8).mul(0);
}

#[test]
fn derived_traits() {
let size = SizeValue::new(8);
Expand Down
Loading