move type def out of unsafe block
from https://github.com/rust-lang/rust/pull/50863#discussion_r190213000 move the union definition outside of the unsafe block
This commit is contained in:
parent
c3733a770e
commit
1977c62339
1 changed files with 4 additions and 6 deletions
|
|
@ -2246,13 +2246,11 @@ impl str {
|
|||
#[inline(always)]
|
||||
#[rustc_const_unstable(feature="const_str_as_bytes")]
|
||||
pub const fn as_bytes(&self) -> &[u8] {
|
||||
unsafe {
|
||||
union Slices<'a> {
|
||||
str: &'a str,
|
||||
slice: &'a [u8],
|
||||
}
|
||||
Slices { str: self }.slice
|
||||
union Slices<'a> {
|
||||
str: &'a str,
|
||||
slice: &'a [u8],
|
||||
}
|
||||
unsafe { Slices { str: self }.slice }
|
||||
}
|
||||
|
||||
/// Converts a mutable string slice to a mutable byte slice. To convert the
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue