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