Skip to content

Commit

Permalink
Address review feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex Saveau committed Nov 21, 2024
1 parent 181ac3b commit 36adbb0
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 13 deletions.
22 changes: 10 additions & 12 deletions src/path/dec_int.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,19 +50,17 @@ impl DecInt {

let mut str_buf = Buffer::new();
let str_buf = str_buf.format(i);
{
assert!(
str_buf.len() < buf.len(),
"{str_buf}{} unsupported.",
core::any::type_name::<Int>()
);
assert!(
str_buf.len() < buf.len(),
"{str_buf}{} unsupported.",
core::any::type_name::<Int>()
);

buf[..str_buf.len()].copy_from_slice(unsafe {
// SAFETY: you can always go from init to uninit
mem::transmute::<&[u8], &[MaybeUninit<u8>]>(str_buf.as_bytes())
});
buf[str_buf.len()] = MaybeUninit::new(0);
}
buf[..str_buf.len()].copy_from_slice(unsafe {
// SAFETY: you can always go from init to uninit
mem::transmute::<&[u8], &[MaybeUninit<u8>]>(str_buf.as_bytes())
});
buf[str_buf.len()] = MaybeUninit::new(0);

Self {
buf,
Expand Down
7 changes: 6 additions & 1 deletion tests/path/dec_int.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,12 @@ fn test_dec_int() {

#[test]
#[should_panic]
fn test_unsupported_dec_int() {
fn test_unsupported_max_u128_dec_int() {
check!(u128::MAX);
}

#[test]
#[should_panic]
fn test_unsupported_min_u128_dec_int() {
check!(i128::MIN);
}

0 comments on commit 36adbb0

Please sign in to comment.