From 9464e27c09e159c09d215eef87a7a8f80a970c89 Mon Sep 17 00:00:00 2001 From: Khyber Sen Date: Mon, 23 Sep 2024 02:02:27 -0700 Subject: [PATCH] `fn AlignedVec::resize`: Use `.expect` of `let else panic!`. --- src/align.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/align.rs b/src/align.rs index 71b174166..01bc7f68e 100644 --- a/src/align.rs +++ b/src/align.rs @@ -186,12 +186,12 @@ impl AlignedVec { let old_len = self.len(); // Resize the underlying vector to have enough chunks for the new length. - // SAFETY: The `new_bytes` calculation must not overflow, ensuring a mathematical match - // with the underlying `inner` buffer size. NOTE: one can still pass ludicrous requested - // buffer lengths, just not unsound ones. - let Some(new_bytes) = mem::size_of::().checked_mul(new_len) else { - panic!("Resizing would overflow the underlying aligned buffer"); - }; + // SAFETY: The `new_bytes` calculation must not overflow, + // ensuring a mathematical match with the underlying `inner` buffer size. + // NOTE: one can still pass ludicrous requested buffer lengths, just not unsound ones. + let new_bytes = mem::size_of::() + .checked_mul(new_len) + .expect("Resizing would overflow the underlying aligned buffer"); let chunk_size = mem::size_of::(); let new_chunks = if (new_bytes % chunk_size) == 0 {