Lines Matching defs:RcBox
19775 struct RcBox<T: ?Sized> {
19794 ptr: NonNull<RcBox<T>>,
19795 phantom: PhantomData<RcBox<T>>,
19811 fn inner(&self) -> &RcBox<T> {
19817 fn from_inner(ptr: NonNull<RcBox<T>>) -> Self {
19821 unsafe fn from_ptr(ptr: *mut RcBox<T>) -> Self {
19843 Box::leak(box RcBox { strong: Cell::new(1), weak: Cell::new(1), value }).into(),
19875 let uninit_ptr: NonNull<_> = Box::leak(box RcBox {
19882 let init_ptr: NonNull<RcBox<T>> = uninit_ptr.cast();
19938 |mem| mem as *mut RcBox<mem::MaybeUninit<T>>,
19969 |mem| mem as *mut RcBox<mem::MaybeUninit<T>>,
19992 Box::leak(Box::try_new(RcBox { strong: Cell::new(1), weak: Cell::new(1), value })?)
20026 |mem| mem as *mut RcBox<mem::MaybeUninit<T>>,
20059 |mem| mem as *mut RcBox<mem::MaybeUninit<T>>,
20168 as *mut RcBox<[mem::MaybeUninit<T>]>
20297 let ptr: *mut RcBox<T> = NonNull::as_ptr(this.ptr);
20346 // Reverse the offset to find the original RcBox.
20348 unsafe { (ptr as *mut RcBox<T>).set_ptr_value((ptr as *mut u8).offset(-offset)) };
20678 let ptr = self.ptr.cast::<RcBox<T>>();
20688 /// Allocates an `RcBox<T>` with sufficient space for
20692 /// and must return back a (potentially fat)-pointer for the `RcBox<T>`.
20696 mem_to_rcbox: impl FnOnce(*mut u8) -> *mut RcBox<T>,
20697 ) -> *mut RcBox<T> {
20700 // `&*(ptr as *const RcBox<T>)`, but this created a misaligned
20702 let layout = Layout::new::<RcBox<()>>().extend(value_layout).unwrap().0.pad_to_align();
20709 /// Allocates an `RcBox<T>` with sufficient space for
20714 /// and must return back a (potentially fat)-pointer for the `RcBox<T>`.
20719 mem_to_rcbox: impl FnOnce(*mut u8) -> *mut RcBox<T>,
20720 ) -> Result<*mut RcBox<T>, AllocError> {
20723 // `&*(ptr as *const RcBox<T>)`, but this created a misaligned
20725 let layout = Layout::new::<RcBox<()>>().extend(value_layout).unwrap().0.pad_to_align();
20730 // Initialize the RcBox
20742 /// Allocates an `RcBox<T>` with sufficient space for an unsized inner value
20743 unsafe fn allocate_for_ptr(ptr: *const T) -> *mut RcBox<T> {
20744 // Allocate for the `RcBox<T>` using the given value.
20749 |mem| (ptr as *mut RcBox<T>).set_ptr_value(mem),
20778 /// Allocates an `RcBox<[T]>` with the given length.
20779 unsafe fn allocate_for_slice(len: usize) -> *mut RcBox<[T]> {
20784 |mem| ptr::slice_from_raw_parts_mut(mem as *mut T, len) as *mut RcBox<[T]>,
20806 // into the new RcBox will be dropped, then the memory freed.
20841 // All clear. Forget the guard so it doesn't free the new RcBox.
21448 // will ever have because RcBox has alignment at least 2.
21450 ptr: NonNull<RcBox<T>>,
21480 Weak { ptr: NonNull::new(usize::MAX as *mut RcBox<T>).expect("MAX is not 0") }
21524 let ptr: *mut RcBox<T> = NonNull::as_ptr(self.ptr);
21528 // a valid payload address, as the payload is at least as aligned as RcBox (usize).
21620 ptr as *mut RcBox<T>
21625 // Thus, we reverse the offset to get the whole RcBox.
21627 unsafe { (ptr as *mut RcBox<T>).set_ptr_value((ptr as *mut u8).offset(-offset)) }
21692 /// Returns `None` when the pointer is dangling and there is no allocated `RcBox`,
21910 impl<T: ?Sized> RcInnerPtr for RcBox<T> {
21951 /// Get the offset within an `RcBox` for the payload behind a pointer.
21958 // Align the unsized value to the end of the RcBox.
21959 // Because RcBox is repr(C), it will always be the last field in memory.
21969 let layout = Layout::new::<RcBox<()>>();
23547 // will ever have because RcBox has alignment at least 2.
25037 // Thus, we reverse the offset to get the whole RcBox.
25788 // Because RcBox is repr(C), it will always be the last field in memory.