mirror of
https://github.com/danbulant/oxc
synced 2026-05-24 12:21:58 +00:00
30 lines
545 B
Rust
30 lines
545 B
Rust
use std::ops::Deref;
|
|
|
|
mod arena;
|
|
|
|
pub use arena::{Box, String, Vec};
|
|
use bumpalo::Bump;
|
|
|
|
#[derive(Debug)]
|
|
pub struct Allocator {
|
|
bump: Bump,
|
|
}
|
|
|
|
// SAFETY: Make Bump Sync and Send, it's our responsibility to never
|
|
// simultaneously mutate across threads.
|
|
unsafe impl Send for Allocator {}
|
|
unsafe impl Sync for Allocator {}
|
|
|
|
impl Default for Allocator {
|
|
fn default() -> Self {
|
|
Self { bump: Bump::new() }
|
|
}
|
|
}
|
|
|
|
impl Deref for Allocator {
|
|
type Target = Bump;
|
|
|
|
fn deref(&self) -> &Self::Target {
|
|
&self.bump
|
|
}
|
|
}
|