cl-arena: Make arena constructors const fn
This commit is contained in:
parent
ecf97801d6
commit
83423f37be
@ -2,7 +2,7 @@
|
|||||||
//!
|
//!
|
||||||
//! An Arena Allocator is a type of allocator which provides stable locations for allocations within
|
//! An Arena Allocator is a type of allocator which provides stable locations for allocations within
|
||||||
//! itself for the entire duration of its lifetime.
|
//! itself for the entire duration of its lifetime.
|
||||||
//!
|
//!
|
||||||
//! [1]: https://raw.githubusercontent.com/rust-lang/rust/master/LICENSE-MIT
|
//! [1]: https://raw.githubusercontent.com/rust-lang/rust/master/LICENSE-MIT
|
||||||
|
|
||||||
#![feature(dropck_eyepatch, new_uninit, strict_provenance)]
|
#![feature(dropck_eyepatch, new_uninit, strict_provenance)]
|
||||||
@ -96,18 +96,18 @@ pub mod typed_arena {
|
|||||||
|
|
||||||
impl<T> Default for TypedArena<T> {
|
impl<T> Default for TypedArena<T> {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self {
|
Self::new()
|
||||||
_drops: Default::default(),
|
|
||||||
chunks: Default::default(),
|
|
||||||
head: Cell::new(ptr::null_mut()),
|
|
||||||
tail: Cell::new(ptr::null_mut()),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T> TypedArena<T> {
|
impl<T> TypedArena<T> {
|
||||||
pub fn new() -> Self {
|
pub const fn new() -> Self {
|
||||||
Self::default()
|
Self {
|
||||||
|
_drops: PhantomData,
|
||||||
|
chunks: RefCell::new(Vec::new()),
|
||||||
|
head: Cell::new(ptr::null_mut()),
|
||||||
|
tail: Cell::new(ptr::null_mut()),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(clippy::mut_from_ref)]
|
#[allow(clippy::mut_from_ref)]
|
||||||
@ -205,17 +205,17 @@ pub mod dropless_arena {
|
|||||||
|
|
||||||
impl Default for DroplessArena {
|
impl Default for DroplessArena {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self {
|
Self::new()
|
||||||
chunks: Default::default(),
|
|
||||||
head: Cell::new(ptr::null_mut()),
|
|
||||||
tail: Cell::new(ptr::null_mut()),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl DroplessArena {
|
impl DroplessArena {
|
||||||
pub fn new() -> Self {
|
pub const fn new() -> Self {
|
||||||
Self::default()
|
Self {
|
||||||
|
chunks: RefCell::new(Vec::new()),
|
||||||
|
head: Cell::new(ptr::null_mut()),
|
||||||
|
tail: Cell::new(ptr::null_mut()),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Allocates a `T` in the [DroplessArena], and returns a mutable reference to it.
|
/// Allocates a `T` in the [DroplessArena], and returns a mutable reference to it.
|
||||||
|
Loading…
Reference in New Issue
Block a user