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 {
48
48
/// Converts `&self` to a `&str` slice.
49
49
#[ inline]
50
50
#[ must_use]
51
- pub fn as_str ( & self ) -> & str {
51
+ pub const fn as_str ( & self ) -> & str {
52
52
// 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 ) }
54
54
}
55
55
56
56
/// Converts `&self` into a byte slice.
57
57
#[ inline]
58
58
#[ must_use]
59
- pub fn as_bytes ( & self ) -> & [ u8 ] {
59
+ pub const fn as_bytes ( & self ) -> & [ u8 ] {
60
60
// 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 ) }
62
62
}
63
63
64
64
/// Returns the entire string as slice of `AsciiChar`s.
You can’t perform that action at this time.
0 commit comments