oxc/crates/oxc_allocator/src/lib.rs
2023-02-11 01:05:07 -08:00

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
}
}