From 385e5dcc058dfd4bb29f95832be11ae8e28bd16c Mon Sep 17 00:00:00 2001 From: Yuki Okushi Date: Tue, 21 Apr 2026 21:56:49 +0900 Subject: [PATCH] perf(bytestring): prefer `from_utf8_unchecked` --- bytestring/src/lib.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bytestring/src/lib.rs b/bytestring/src/lib.rs index 16e26cf9..e50a0477 100644 --- a/bytestring/src/lib.rs +++ b/bytestring/src/lib.rs @@ -185,7 +185,8 @@ impl From> for ByteString { impl From for String { #[inline] fn from(value: ByteString) -> Self { - String::from_utf8(value.0.into()).expect("ByteString invariant violated") + // SAFETY: UTF-8 validity is guaranteed during construction. + unsafe { String::from_utf8_unchecked(value.0.into()) } } }