Auto merge of #47004 - nvzqz:rc-conversions, r=bluss,kennytm
Remove transmute in From<&str> impls for Arc/Rc Performs conversion via raw pointer casts.
This commit is contained in:
commit
e03742368f
@ -1377,7 +1377,8 @@ impl<'a, T: Clone> From<&'a [T]> for Arc<[T]> {
|
|||||||
impl<'a> From<&'a str> for Arc<str> {
|
impl<'a> From<&'a str> for Arc<str> {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn from(v: &str) -> Arc<str> {
|
fn from(v: &str) -> Arc<str> {
|
||||||
unsafe { mem::transmute(<Arc<[u8]>>::from(v.as_bytes())) }
|
let arc = Arc::<[u8]>::from(v.as_bytes());
|
||||||
|
unsafe { Arc::from_raw(Arc::into_raw(arc) as *const str) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1099,7 +1099,8 @@ impl<'a, T: Clone> From<&'a [T]> for Rc<[T]> {
|
|||||||
impl<'a> From<&'a str> for Rc<str> {
|
impl<'a> From<&'a str> for Rc<str> {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn from(v: &str) -> Rc<str> {
|
fn from(v: &str) -> Rc<str> {
|
||||||
unsafe { mem::transmute(<Rc<[u8]>>::from(v.as_bytes())) }
|
let rc = Rc::<[u8]>::from(v.as_bytes());
|
||||||
|
unsafe { Rc::from_raw(Rc::into_raw(rc) as *const str) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user