Skip to content

Commit

Permalink
move type def out of unsafe block
Browse files Browse the repository at this point in the history
from #50863 (comment)

move the union definition outside of the unsafe block
  • Loading branch information
fbstj authored May 23, 2018
1 parent c3733a7 commit 1977c62
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/libcore/str/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 1977c62

Please sign in to comment.