/// ```
#[stable(feature = "rc_raw", since = "1.17.0")]
pub fn into_raw(this: Self) -> *const T {
- let ptr: *const T = &*this;
+ let ptr: *mut RcBox<T> = NonNull::as_ptr(this.ptr);
+ let fake_ptr = ptr as *mut T;
mem::forget(this);
- ptr
+
+ unsafe {
+ let offset = data_offset(&(*ptr).value);
+ set_data_ptr(fake_ptr, (ptr as *mut u8).offset(offset))
+ }
}
/// Constructs an `Rc` from a raw pointer.
/// ```
#[stable(feature = "rc_raw", since = "1.17.0")]
pub fn into_raw(this: Self) -> *const T {
- let ptr: *const T = &*this;
+ let ptr: *mut ArcInner<T> = NonNull::as_ptr(this.ptr);
+ let fake_ptr = ptr as *mut T;
mem::forget(this);
- ptr
+
+ unsafe {
+ let offset = data_offset(&(*ptr).data);
+ set_data_ptr(fake_ptr, (ptr as *mut u8).offset(offset))
+ }
}
/// Constructs an `Arc` from a raw pointer.