mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-02 15:32:06 +00:00
Rollup merge of #50995 - fbstj:patch-1, r=cramertj
move type out of unsafe block from https://github.com/rust-lang/rust/pull/50863#discussion_r190213000 move the union definition outside of the unsafe block as it's definition is not unsafe
This commit is contained in:
commit
99de8ab38b
@ -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…
Reference in New Issue
Block a user