diff --git a/lexical-parse-float/src/bigint.rs b/lexical-parse-float/src/bigint.rs index 2e9fa6b6..0738f0a0 100644 --- a/lexical-parse-float/src/bigint.rs +++ b/lexical-parse-float/src/bigint.rs @@ -586,8 +586,7 @@ impl StackVec { pub fn from_u16(x: u16) -> Self { let mut vec = Self::new(); assert!(1 <= vec.capacity()); - // SAFETY: safe since we can always add 1 item. - unsafe { vec.push_unchecked(x as Limb) }; + _ = vec.try_push(x as Limb); vec.normalize(); vec } @@ -598,8 +597,7 @@ impl StackVec { let mut vec = Self::new(); debug_assert!(1 <= vec.capacity()); assert!(1 <= SIZE); - // SAFETY: safe since we can always add 1 item (validated in the asset). - unsafe { vec.push_unchecked(x as Limb) }; + _ = vec.try_push(x as Limb); vec.normalize(); vec } @@ -611,14 +609,10 @@ impl StackVec { debug_assert!(2 <= vec.capacity()); assert!(2 <= SIZE); if LIMB_BITS == 32 { - // SAFETY: safe since we can always add 2 items (validated in the asset). - unsafe { - vec.push_unchecked(x as Limb); - vec.push_unchecked((x >> 32) as Limb); - } + _ = vec.try_push(x as Limb); + _ = vec.try_push((x >> 32) as Limb); } else { - // SAFETY: safe since we can always add 1 item. - unsafe { vec.push_unchecked(x as Limb) }; + _ = vec.try_push(x as Limb); } vec.normalize(); vec