Lines Matching defs:A

77 /// `self.0` is always properly aligned and either points to memory allocated with `A` or, for
81 pub struct Box<#[pointee] T: ?Sized, A: Allocator>(NonNull<T>, PhantomData<A>);
121 unsafe impl<T, A: Allocator> ZeroableOption for Box<T, A> {}
124 unsafe impl<T, A> Send for Box<T, A>
127 A: Allocator,
132 unsafe impl<T, A> Sync for Box<T, A>
135 A: Allocator,
139 impl<T, A> Box<T, A>
142 A: Allocator,
144 /// Creates a new `Box<T, A>` from a raw pointer.
148 /// For non-ZSTs, `raw` must point at an allocation allocated with `A` that is sufficiently
160 /// Consumes the `Box<T, A>` and returns a raw pointer.
182 /// Consumes and leaks the `Box<T, A>` and returns a mutable reference.
193 impl<T, A> Box<MaybeUninit<T>, A>
195 A: Allocator,
197 /// Converts a `Box<MaybeUninit<T>, A>` to a `Box<T, A>`.
205 pub unsafe fn assume_init(self) -> Box<T, A> {
210 // safe to reconstruct the `Box` as `Box<T, A>`.
214 /// Writes the value and converts to `Box<T, A>`.
215 pub fn write(mut self, value: T) -> Box<T, A> {
223 impl<T, A> Box<T, A>
225 A: Allocator,
227 /// Creates a new `Box<T, A>` and initializes its contents with `x`.
229 /// New memory is allocated with `A`. The allocation may fail, in which case an error is
236 /// Creates a new `Box<T, A>` with uninitialized contents.
238 /// New memory is allocated with `A`. The allocation may fail, in which case an error is
250 pub fn new_uninit(flags: Flags) -> Result<Box<MaybeUninit<T>, A>, AllocError> {
252 let ptr = A::alloc(layout, flags, NumaNode::NO_NODE)?;
254 // INVARIANT: `ptr` is either a dangling pointer or points to memory allocated with `A`,
259 /// Constructs a new `Pin<Box<T, A>>`. If `T` does not implement [`Unpin`], then `x` will be
262 pub fn pin(x: T, flags: Flags) -> Result<Pin<Box<T, A>>, AllocError>
264 A: 'static,
269 /// Construct a pinned slice of elements `Pin<Box<[T], A>>`.
315 ) -> Result<Pin<Box<[T], A>>, E>
321 let mut buffer = super::Vec::<T, A>::with_capacity(len, flags)?;
341 // SAFETY: `slice` points to an allocation allocated with `A` (`buffer`) and holds a valid
346 /// Convert a [`Box<T,A>`] to a [`Pin<Box<T,A>>`]. If `T` does not implement
353 fn forget_contents(this: Self) -> Box<MaybeUninit<T>, A> {
373 pub fn drop_contents(this: Self) -> Box<MaybeUninit<T>, A> {
392 impl<T, A> From<Box<T, A>> for Pin<Box<T, A>>
395 A: Allocator,
397 /// Converts a `Box<T, A>` into a `Pin<Box<T, A>>`. If `T` does not implement [`Unpin`], then
401 fn from(b: Box<T, A>) -> Self {
402 // SAFETY: The value wrapped inside a `Pin<Box<T, A>>` cannot be moved or replaced as long
408 impl<T, A> InPlaceWrite<T> for Box<MaybeUninit<T>, A>
410 A: Allocator + 'static,
412 type Initialized = Box<T, A>;
433 impl<T, A> InPlaceInit<T> for Box<T, A>
435 A: Allocator + 'static,
444 Box::<_, A>::new_uninit(flags)?.write_pin_init(init)
452 Box::<_, A>::new_uninit(flags)?.write_init(init)
457 // pointer to `T` allocated by `A`.
458 unsafe impl<T: 'static, A> ForeignOwnable for Box<T, A>
460 A: Allocator,
462 const FOREIGN_ALIGN: usize = if core::mem::align_of::<T>() < A::MIN_ALIGN {
463 A::MIN_ALIGN
496 // pointer to `T` allocated by `A`.
497 unsafe impl<T: 'static, A> ForeignOwnable for Pin<Box<T, A>>
499 A: Allocator,
501 const FOREIGN_ALIGN: usize = <Box<T, A> as ForeignOwnable>::FOREIGN_ALIGN;
540 impl<T, A> Deref for Box<T, A>
543 A: Allocator,
554 impl<T, A> DerefMut for Box<T, A>
557 A: Allocator,
584 impl<T, A> Borrow<T> for Box<T, A>
587 A: Allocator,
612 impl<T, A> BorrowMut<T> for Box<T, A>
615 A: Allocator,
622 impl<T, A> fmt::Display for Box<T, A>
625 A: Allocator,
632 impl<T, A> fmt::Debug for Box<T, A>
635 A: Allocator,
642 impl<T, A> Drop for Box<T, A>
645 A: Allocator,
654 // - `self.0` was previously allocated with `A`.
656 unsafe { A::free(self.0.cast(), layout) };