We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
impl AsMut<str> for AsciiChar
1 parent 3f04fd5 commit 8804742Copy full SHA for 8804742
library/core/src/ascii/ascii_char.rs
@@ -1177,6 +1177,18 @@ impl AsRef<str> for AsciiChar {
1177
}
1178
1179
1180
+#[unstable(feature = "ascii_char", issue = "110998")]
1181
+impl AsMut<str> for AsciiChar {
1182
+ #[inline(always)]
1183
+ fn as_mut(&mut self) -> &mut str {
1184
+ let ascii_ptr: *mut [Self] = crate::slice::from_mut(self);
1185
+ let str_ptr = ascii_ptr as *mut str;
1186
+ // SAFETY: Each ASCII codepoint in UTF-8 is encoded as one single-byte
1187
+ // code unit having the same value as the ASCII byte.
1188
+ unsafe { &mut *str_ptr }
1189
+ }
1190
+}
1191
+
1192
impl [AsciiChar] {
1193
/// Views this slice of ASCII characters as a UTF-8 `str`.
1194
#[unstable(feature = "ascii_char", issue = "110998")]
0 commit comments