Skip to content

Commit b8d4b45

Browse files
ZenithsizThomas Bahn
authored and
Thomas Bahn
committed
Fixed usage of String in a #[no_std] environment in ascii_str::tests.
1 parent 4c366ea commit b8d4b45

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

src/ascii_str.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff 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.

0 commit comments

Comments
 (0)