File tree Expand file tree Collapse file tree 1 file changed +4
-5
lines changed
Expand file tree Collapse file tree 1 file changed +4
-5
lines changed Original file line number Diff line number Diff line change @@ -1184,11 +1184,10 @@ mod tests {
11841184 let ascii_str = arr. as_ref ( ) . into ( ) ;
11851185 let mut mut_arr = arr; // Note: We need a second copy to prevent overlapping mutable borrows.
11861186 let mut_ascii_str = mut_arr. as_mut ( ) . into ( ) ;
1187- let mut_arr_mut_ref: & mut [ AsciiChar ] = & mut [ AsciiChar :: A ] ;
1188- let mut string = "A" . to_string ( ) ;
1189- let mut string2 = "A" . to_string ( ) ;
1190- let string_mut = string. as_mut_str ( ) ;
1191- let string_mut_bytes = unsafe { string2. as_bytes_mut ( ) } ; // SAFETY: We don't modify it
1187+ let mut_arr_mut_ref: & mut [ AsciiChar ] = & mut [ AsciiChar :: A ] ;
1188+ let mut string_bytes = [ b'A' ] ;
1189+ let string_mut = unsafe { std:: str:: from_utf8_unchecked_mut ( & mut string_bytes) } ; // SAFETY: 'A' is a valid string.
1190+ let string_mut_bytes: & mut [ u8 ] = & mut [ b'A' ] ;
11921191
11931192 // Note: This is a trick because `rustfmt` doesn't support
11941193 // attributes on blocks yet.
You can’t perform that action at this time.
0 commit comments