diff options
| author | Joe ST <joe@fbstj.net> | 2018-05-23 15:01:11 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-05-23 15:01:11 +0100 |
| commit | 1977c62339acceabe711d8ca6bf9404475c7f75d (patch) | |
| tree | 1c5cf18ecdf8be9823025ab61183587e87c2e00d | |
| parent | c3733a770edb1eb0f8b8943e7a0a962f4e1e91a8 (diff) | |
| download | rust-1977c62339acceabe711d8ca6bf9404475c7f75d.tar.gz rust-1977c62339acceabe711d8ca6bf9404475c7f75d.zip | |
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
| -rw-r--r-- | src/libcore/str/mod.rs | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/src/libcore/str/mod.rs b/src/libcore/str/mod.rs index 70aaf10f421..13d808ede5f 100644 --- a/src/libcore/str/mod.rs +++ b/src/libcore/str/mod.rs @@ -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 |
