kul 0.1.2

Parser for a unique textual notation that can be used as both a data format and a markup language and that has powerful extensibility of both lexical syntax and semantics. Inspired by the little-known Curl programming language. Has no unsafe code and has no external dependencies. This is the full crate that builds on and re-exports the core crate and that uses the std library.
Documentation
use std::marker::PhantomData;

use crate::{
    parser::{DatumAllocator, AllocError},
    datum::{DatumArc, ArcDatum},
    Text,
};


/// A [`DatumAllocator`] for generic `Datum` types which allocates `Datum`
/// values in heap-allocated `Arc`s.
///
/// [`DatumAllocator`]: ../../kul_core/parser/trait.DatumAllocator.html
#[derive(Debug)]
pub struct ArcDatumAllocator<TT, ET>(PhantomData<(*const TT, *const ET)>);

/// Must implement this manually because deriving would place unwanted bounds on
/// the type parameters.
impl<TT, ET> Default for ArcDatumAllocator<TT, ET>
    where TT: Text,
{
    /// This type only has one, default, value.
    #[inline]
    fn default() -> Self {
        Self(PhantomData)
    }
}

impl<TT, ET> DatumAllocator for ArcDatumAllocator<TT, ET>
    where TT: Text,
{
    type TT = TT;
    type ET = ET;
    type DR = DatumArc<Self::TT, Self::ET>;

    #[inline]
    fn new_datum(&mut self, from: ArcDatum<Self::TT, Self::ET>)
                 -> Result<Self::DR, AllocError>
    {
        Ok(DatumArc::new(from))
    }
}


// Note: Tested by the arc_alloc integration test.