diff --git a/src/string.rs b/src/string.rs index 907dee1..be868ff 100644 --- a/src/string.rs +++ b/src/string.rs @@ -1,7 +1,7 @@ use alloc::{ borrow::{Cow, ToOwned}, boxed::Box, - string::{String, ToString}, + string::{String}, sync::Arc, }; use core::{borrow::Borrow, fmt::Write as _, hash::Hash, str::FromStr}; @@ -315,12 +315,18 @@ impl From for FixedString { } impl From> for String { + fn from(value: FixedString) -> Self { + Box::::from(value).into() + } +} + +impl From> for Box { fn from(value: FixedString) -> Self { match value.0 { + FixedStringRepr::Inline(a) => a.as_str().into(), + FixedStringRepr::Static(a) => a.as_str().into(), // SAFETY: Self holds the type invariant that the array is UTF-8. - FixedStringRepr::Heap(a) => unsafe { String::from_utf8_unchecked(a.into()) }, - FixedStringRepr::Inline(a) => a.as_str().to_string(), - FixedStringRepr::Static(a) => a.as_str().to_string(), + FixedStringRepr::Heap(a) => unsafe { alloc::str::from_boxed_utf8_unchecked(a.into()) }, } } }