Make the node type generic.

This commit is contained in:
Tom Alexander 2022-11-26 21:02:52 -05:00
parent 7a241353b5
commit e888c0e66f
Signed by: talexander
GPG Key ID: D3A179C9A53C0EDE
1 changed files with 5 additions and 5 deletions

View File

@ -6,7 +6,7 @@ use super::text::bold_end;
use super::text::Res; use super::text::Res;
type Matcher = dyn for<'s> Fn(&'s str) -> IResult<&'s str, &'s str, VerboseError<&'s str>>; type Matcher = dyn for<'s> Fn(&'s str) -> IResult<&'s str, &'s str, VerboseError<&'s str>>;
type Link<'r> = Option<&'r Node<'r>>; type Link<'r, T> = Option<&'r Node<'r, T>>;
pub trait OrgModeContext<'r> { pub trait OrgModeContext<'r> {
// todo // todo
@ -25,14 +25,14 @@ pub enum ChainBehavior<'r> {
IgnoreParent(Option<&'r Matcher>), IgnoreParent(Option<&'r Matcher>),
} }
struct Node<'r> { struct Node<'r, T: 'r + ?Sized> {
elem: &'r dyn OrgModeContext<'r>, elem: &'r T,
parent: Link<'r>, parent: Link<'r, T>,
} }
struct ContextTree<'r> { struct ContextTree<'r> {
// Not using Link so the ContextTree can own this node // Not using Link so the ContextTree can own this node
head: Option<Node<'r>>, head: Option<Node<'r, dyn OrgModeContext<'r>>>,
} }
impl<'r> ContextTree<'r> { impl<'r> ContextTree<'r> {