mirror of
https://github.com/danbulant/oxc
synced 2026-05-24 12:21:58 +00:00
parent
24d209cdd4
commit
a6d9356ffa
1 changed files with 25 additions and 1 deletions
|
|
@ -1,4 +1,4 @@
|
|||
use std::ops::Deref;
|
||||
use std::{convert::From, ops::Deref};
|
||||
|
||||
mod arena;
|
||||
|
||||
|
|
@ -10,6 +10,12 @@ pub struct Allocator {
|
|||
bump: Bump,
|
||||
}
|
||||
|
||||
impl From<Bump> for Allocator {
|
||||
fn from(bump: Bump) -> Self {
|
||||
Self { bump }
|
||||
}
|
||||
}
|
||||
|
||||
impl Deref for Allocator {
|
||||
type Target = Bump;
|
||||
|
||||
|
|
@ -17,3 +23,21 @@ impl Deref for Allocator {
|
|||
&self.bump
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use std::ops::Deref;
|
||||
|
||||
use crate::Allocator;
|
||||
use bumpalo::Bump;
|
||||
|
||||
#[test]
|
||||
fn test_api() {
|
||||
let bump = Bump::new();
|
||||
let allocator: Allocator = bump.into();
|
||||
#[allow(clippy::explicit_deref_methods)]
|
||||
{
|
||||
_ = allocator.deref();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue