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 ptr = thin_arc.with_arc(Arc::clone).into_raw();// store the raw pointer somewhere. then laterlet thin_arc = ThinArc::from_data_raw(ptr);
I would go through Arc::from_raw(ptr).into_thin() but that doesn't work because from_raw needs T: Sized.
What I'm imagining is in this impl there is something like
/// Reconstruct the Arc<HeaderSliceWithLength<H, [T]>> from a raw pointer obtained from into_raw()#[inline]pubunsafefnfrom_thin_raw(ptr:*constHeaderSliceWithLength<H,[T]>) -> ThinArc<H,T>{let data_ptr = ptr as*const[u8]as*constu8;let thin_ptr = data_ptr.sub(offset_of!(ArcInner<HeaderSliceWithLength<H,[T;0]>>, data));ThinArc{ptr:unsafe{
ptr::NonNull::new_unchecked(
thin_ptr as*mutArcInner<HeaderSliceWithLength<H,[T;0]>>,)},phantom:PhantomData,}}
The core idea is that I have ThinArc<H, Slot> where each Slot stores it's index in the slice.
Given a *const Slot, I can count back the index and get back the original ThinArc<H, Slot>. Almost everything was working, except for the drop() impl of the RawWaker, since I couldn't construct the arc with the correct size to deallocate.
The text was updated successfully, but these errors were encountered:
I have a setup where I want to do
I would go through
Arc::from_raw(ptr).into_thin()
but that doesn't work becausefrom_raw
needsT: Sized
.What I'm imagining is in this impl there is something like
For context, I was trying to move some of the functionality from https://github.com/conradludgate/futures-buffered/blob/main/src/arc_slice.rs into triomphe.
The core idea is that I have
ThinArc<H, Slot>
where eachSlot
stores it's index in the slice.Given a
*const Slot
, I can count back the index and get back the originalThinArc<H, Slot>
. Almost everything was working, except for thedrop()
impl of the RawWaker, since I couldn't construct the arc with the correct size to deallocate.The text was updated successfully, but these errors were encountered: