File tree Expand file tree Collapse file tree 1 file changed +10
-4
lines changed
Expand file tree Collapse file tree 1 file changed +10
-4
lines changed Original file line number Diff line number Diff line change 11use alloc:: {
22 borrow:: { Cow , ToOwned } ,
33 boxed:: Box ,
4- string:: { String , ToString } ,
4+ string:: { String } ,
55 sync:: Arc ,
66} ;
77use core:: { borrow:: Borrow , fmt:: Write as _, hash:: Hash , str:: FromStr } ;
@@ -315,12 +315,18 @@ impl<LenT: ValidLength> From<char> for FixedString<LenT> {
315315}
316316
317317impl < LenT : ValidLength > From < FixedString < LenT > > for String {
318+ fn from ( value : FixedString < LenT > ) -> Self {
319+ Box :: < str > :: from ( value) . into ( )
320+ }
321+ }
322+
323+ impl < LenT : ValidLength > From < FixedString < LenT > > for Box < str > {
318324 fn from ( value : FixedString < LenT > ) -> Self {
319325 match value. 0 {
326+ FixedStringRepr :: Inline ( a) => a. as_str ( ) . into ( ) ,
327+ FixedStringRepr :: Static ( a) => a. as_str ( ) . into ( ) ,
320328 // SAFETY: Self holds the type invariant that the array is UTF-8.
321- FixedStringRepr :: Heap ( a) => unsafe { String :: from_utf8_unchecked ( a. into ( ) ) } ,
322- FixedStringRepr :: Inline ( a) => a. as_str ( ) . to_string ( ) ,
323- FixedStringRepr :: Static ( a) => a. as_str ( ) . to_string ( ) ,
329+ FixedStringRepr :: Heap ( a) => unsafe { alloc:: str:: from_boxed_utf8_unchecked ( a. into ( ) ) } ,
324330 }
325331 }
326332}
You can’t perform that action at this time.
0 commit comments