Add the with_additional_node function to the ContextTree.
This commit is contained in:
parent
c0e51298b6
commit
bc91775880
@ -23,7 +23,7 @@ impl<T> List<T> {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_data(&self) -> &T {
|
||||
&self.data
|
||||
pub fn get_data(&self) -> Option<&T> {
|
||||
self.head.map(|rc_node| &rc_node.as_ref().data)
|
||||
}
|
||||
}
|
||||
|
@ -13,6 +13,13 @@ impl<'r> ContextTree<'r> {
|
||||
pub fn new() -> Self {
|
||||
ContextTree { tree: List::new() }
|
||||
}
|
||||
|
||||
pub fn with_additional_node<'x>(&self, data: ContextElement<'x>) -> ContextTree<'x> {
|
||||
let new_list = self.tree.push_front(data);
|
||||
ContextTree {
|
||||
tree: new_list,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub enum ContextElement<'r> {
|
||||
|
@ -83,7 +83,7 @@ where
|
||||
pub fn document(input: &str) -> Res<&str, Vec<(Vec<TextElement>, &str)>> {
|
||||
let initial_context: ContextTree<'_> = ContextTree::new();
|
||||
let paragraph_parser = parser_with_context!(paragraph);
|
||||
let ret = many1(paragraph_parser(&initial_context))(input);
|
||||
let ret = many1(paragraph_parser(initial_context))(input);
|
||||
ret
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user