From f645b0cb75c924f95198684ab4c71d4e98561c2b Mon Sep 17 00:00:00 2001 From: Tom Alexander Date: Sat, 26 Nov 2022 21:07:56 -0500 Subject: [PATCH] Make the node type inside the ContextTree generic but the implementation still explicitly uses dyn OrgModeContext. --- src/parser/new_context.rs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/parser/new_context.rs b/src/parser/new_context.rs index 5c38ecaa..12888ef0 100644 --- a/src/parser/new_context.rs +++ b/src/parser/new_context.rs @@ -30,17 +30,20 @@ struct Node<'r, T: 'r + ?Sized> { parent: Link<'r, T>, } -struct ContextTree<'r> { +struct ContextTree<'r, T: 'r + ?Sized> { // Not using Link so the ContextTree can own this node - head: Option>>, + head: Option>, } -impl<'r> ContextTree<'r> { +impl<'r> ContextTree<'r, dyn OrgModeContext<'r>> { pub fn new() -> Self { ContextTree { head: None } } - pub fn with_additional_node(&'r self, new_elem: &'r dyn OrgModeContext<'r>) -> ContextTree<'r> { + pub fn with_additional_node( + &'r self, + new_elem: &'r dyn OrgModeContext<'r>, + ) -> ContextTree<'r, dyn OrgModeContext<'r>> { let new_node = Node { elem: new_elem, parent: self.head.as_ref(),