hrtb not working.
This commit is contained in:
parent
9673917a3c
commit
7346f5e850
@ -68,3 +68,47 @@ impl<'r> ContextElement<'r> for PreviousElementNode<'r> {
|
||||
ChainBehavior::AndParent(None)
|
||||
}
|
||||
}
|
||||
|
||||
pub struct ContextTree<'r, T> {
|
||||
head: Option<Node<'r, T>>,
|
||||
}
|
||||
|
||||
impl<'r, T> ContextTree<'r, T>
|
||||
where
|
||||
T: for<'s> ContextElement<'s>,
|
||||
{
|
||||
pub fn new() -> Self {
|
||||
ContextTree { head: None }
|
||||
}
|
||||
|
||||
pub fn with_additional_node<F: for<'s> ContextElement<'s>>(
|
||||
&'r self,
|
||||
element: F,
|
||||
) -> ContextTree<'r, F> {
|
||||
let new_node = {
|
||||
let parent: Option<&dyn NodeType<'_>> = match &self.head {
|
||||
Some(node) => Some(node),
|
||||
None => None,
|
||||
};
|
||||
Node {
|
||||
data: element,
|
||||
parent,
|
||||
}
|
||||
};
|
||||
|
||||
ContextTree {
|
||||
head: Some(new_node),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn test_context() {
|
||||
let foo = "foo";
|
||||
let context = ContextTree::new();
|
||||
let child1_context = PreviousElementNode { dummy: foo };
|
||||
let child1 = context.with_additional_node(&child1_context);
|
||||
let child2_context = FailMatcherNode {
|
||||
fail_matcher: ChainBehavior::AndParent(Some(&recognize_bold_end)),
|
||||
};
|
||||
let child2 = child1.with_additional_node(&child2_context);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user