Relax A: Clone bound for rc::Weak::into_raw_and_alloc

This commit is contained in:
Daria Sukhonina 2024-04-27 11:59:50 +03:00
parent 9adafa7f8d
commit 255a1e9554

View File

@ -3029,13 +3029,10 @@ pub fn into_raw(self) -> *const T {
/// [`as_ptr`]: Weak::as_ptr
#[inline]
#[unstable(feature = "allocator_api", issue = "32838")]
pub fn into_raw_and_alloc(self) -> (*const T, A)
where
A: Clone,
{
let result = self.as_ptr();
let alloc = self.alloc.clone();
mem::forget(self);
pub fn into_raw_and_alloc(self) -> (*const T, A) {
let rc = mem::ManuallyDrop::new(self);
let result = rc.as_ptr();
let alloc = unsafe { ptr::read(&rc.alloc) };
(result, alloc)
}