1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
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))
}
}