You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
let data_ptr = &mut fat_ptr as*mut*constTas*mut*mut();
assert_eq!(*data_ptr as*const(), t as*constTas*const());
*data_ptr = <TasDynClone>::clone_box(t);
}
As implemented, this relies on the fact that the layout of fat pointers puts the data pointer first and the fat part second. This is currently true, and the way that the compiler/stdlib implement this functionality, but could potentially change in the future. Whatever form set_ptr_value ends up stabilizing in will be the sound way to accomplish this.
(Since DynClone::clone_box is a private non-public API, it'll probably want to change its signature to match whatever the argument for set_ptr_value settles on.)
The text was updated successfully, but these errors were encountered:
dtolnay
changed the title
This relies on compiler-internal details, but won't have to in the future
Use <*mut T>::set_ptr_value when available
Aug 15, 2020
dtolnay
changed the title
Use <*mut T>::set_ptr_value when available
Use <*mut T>::with_metadata_of when available
Jul 15, 2023
The needed API just hit nightly:
<*mut T>::set_ptr_value(self, *mut u8) -> *mut T
The problematic section:
dyn-clone/src/lib.rs
Lines 109 to 113 in 754c7c7
As implemented, this relies on the fact that the layout of fat pointers puts the data pointer first and the fat part second. This is currently true, and the way that the compiler/stdlib implement this functionality, but could potentially change in the future. Whatever form
set_ptr_value
ends up stabilizing in will be the sound way to accomplish this.(Since
DynClone::clone_box
is a private non-public API, it'll probably want to change its signature to match whatever the argument forset_ptr_value
settles on.)The text was updated successfully, but these errors were encountered: