get_fail_matcher implemented.
This commit is contained in:
parent
4a2b633f9c
commit
9673917a3c
@ -27,9 +27,9 @@ pub trait NodeType<'p> {
|
||||
|
||||
impl<'p, T> NodeType<'p> for Node<'p, T>
|
||||
where
|
||||
T: ContextElement,
|
||||
T: for<'s> ContextElement<'s>,
|
||||
{
|
||||
fn get_data(&self) -> &dyn ContextElement {
|
||||
fn get_data<'s>(&'s self) -> &dyn ContextElement {
|
||||
&self.data
|
||||
}
|
||||
|
||||
@ -38,7 +38,9 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
pub trait ContextElement {}
|
||||
pub trait ContextElement<'r> {
|
||||
fn get_fail_matcher(&self) -> ChainBehavior<'r>;
|
||||
}
|
||||
|
||||
struct FailMatcherNode<'r> {
|
||||
fail_matcher: ChainBehavior<'r>,
|
||||
@ -48,7 +50,21 @@ struct PreviousElementNode<'r> {
|
||||
dummy: &'r str,
|
||||
}
|
||||
|
||||
enum ChainBehavior<'r> {
|
||||
#[derive(Clone)]
|
||||
pub enum ChainBehavior<'r> {
|
||||
AndParent(Option<&'r Matcher>),
|
||||
IgnoreParent(Option<&'r Matcher>),
|
||||
}
|
||||
|
||||
impl<'r> ContextElement<'r> for FailMatcherNode<'r> {
|
||||
fn get_fail_matcher(&self) -> ChainBehavior<'r> {
|
||||
// TODO: Remove this clone
|
||||
self.fail_matcher.clone()
|
||||
}
|
||||
}
|
||||
|
||||
impl<'r> ContextElement<'r> for PreviousElementNode<'r> {
|
||||
fn get_fail_matcher(&self) -> ChainBehavior<'r> {
|
||||
ChainBehavior::AndParent(None)
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user