use std::marker::PhantomData;
use crate::{
parser::{DatumAllocator, AllocError},
datum::{DatumBox, BoxDatum},
Text,
};
#[derive(Debug)]
pub struct BoxDatumAllocator<TT, ET>(PhantomData<(*const TT, *const ET)>);
impl<TT, ET> Default for BoxDatumAllocator<TT, ET>
where TT: Text,
{
#[inline]
fn default() -> Self {
Self(PhantomData)
}
}
impl<TT, ET> DatumAllocator for BoxDatumAllocator<TT, ET>
where TT: Text,
{
type TT = TT;
type ET = ET;
type DR = DatumBox<Self::TT, Self::ET>;
#[inline]
fn new_datum(&mut self, from: BoxDatum<Self::TT, Self::ET>)
-> Result<Self::DR, AllocError>
{
Ok(DatumBox::new(from))
}
}