未验证 提交 99de8ab3 编写于 作者: K kennytm

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
......@@ -2246,13 +2246,11 @@ pub fn is_char_boundary(&self, index: usize) -> bool {
#[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
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册