Open douglas-raillard-arm opened 1 year ago
This was intentional to keep bumpalo::boxed::Box
a single word.
Maybe that could become opt-in with a generic parameter, defaulting to current behavior ? Something like:
pub struct Box<'a, T: ?Sized, Alloc=()>(&'a mut T, alloc: Alloc);
type CloneableBox<'a, T> = Box<'a, T, &'a Bump>;
impl<'a, T: ?Sized> Clone for Box<'a, T, &'a Bump> {
...
}
In oxc, we achieve this with a CloneIn
trait.
https://github.com/oxc-project/oxc/blob/main/crates/oxc_allocator/src/clone_in.rs something similar might be useful to you.
Bumpalo's
Box
is missing a Clone implementation, which is a pretty big departure fromstd
'sBox
. Bringing it back would require storing a&Bump
inside theBox
in addition to the&mut T
to be able to allocate a new value inside the same arena.That is also the way
std
is implemented: https://doc.rust-lang.org/src/alloc/boxed.rs.html#198-201