File tree Expand file tree Collapse file tree 1 file changed +4
-4
lines changed Expand file tree Collapse file tree 1 file changed +4
-4
lines changed Original file line number Diff line number Diff line change @@ -48,17 +48,17 @@ impl AsciiStr {
4848 /// Converts `&self` to a `&str` slice.
4949 #[ inline]
5050 #[ must_use]
51- pub fn as_str ( & self ) -> & str {
51+ pub const fn as_str ( & self ) -> & str {
5252 // SAFETY: All variants of `AsciiChar` are valid bytes for a `str`.
53- unsafe { & * ( self as * const AsciiStr as * const str ) }
53+ unsafe { mem :: transmute ( self ) }
5454 }
5555
5656 /// Converts `&self` into a byte slice.
5757 #[ inline]
5858 #[ must_use]
59- pub fn as_bytes ( & self ) -> & [ u8 ] {
59+ pub const fn as_bytes ( & self ) -> & [ u8 ] {
6060 // SAFETY: All variants of `AsciiChar` are valid `u8`, given they're `repr(u8)`.
61- unsafe { & * ( self as * const AsciiStr as * const [ u8 ] ) }
61+ unsafe { mem :: transmute ( self ) }
6262 }
6363
6464 /// Returns the entire string as slice of `AsciiChar`s.
You can’t perform that action at this time.
0 commit comments