mirror of
https://github.com/danbulant/oxc
synced 2026-05-24 12:21:58 +00:00
docs(allocator): clarify docs for Box (#6625)
Clarify the consequences of storing `Drop` types in `oxc_allocator::Box`.
This commit is contained in:
parent
2673397122
commit
9f555d7c7f
1 changed files with 9 additions and 3 deletions
|
|
@ -16,10 +16,16 @@ use serde::{Serialize, Serializer};
|
||||||
|
|
||||||
use crate::Allocator;
|
use crate::Allocator;
|
||||||
|
|
||||||
/// A Box without [`Drop`].
|
/// A `Box` without [`Drop`], which stores its data in the arena allocator.
|
||||||
///
|
///
|
||||||
/// This is used for over coming self-referential structs.
|
/// Should only be used for storing AST types.
|
||||||
/// It is a memory leak if the boxed value has a [`Drop`] implementation.
|
///
|
||||||
|
/// Must NOT be used to store types which have a [`Drop`] implementation.
|
||||||
|
/// `T::drop` will NOT be called on the `Box`'s contents when the `Box` is dropped.
|
||||||
|
/// If `T` owns memory outside of the arena, this will be a memory leak.
|
||||||
|
///
|
||||||
|
/// Note: This is not a soundness issue, as Rust does not support relying on `drop`
|
||||||
|
/// being called to guarantee soundness.
|
||||||
pub struct Box<'alloc, T: ?Sized>(NonNull<T>, PhantomData<(&'alloc (), T)>);
|
pub struct Box<'alloc, T: ?Sized>(NonNull<T>, PhantomData<(&'alloc (), T)>);
|
||||||
|
|
||||||
impl<'alloc, T> Box<'alloc, T> {
|
impl<'alloc, T> Box<'alloc, T> {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue