Make the node type inside the ContextTree generic but the implementation still explicitly uses dyn OrgModeContext.
This commit is contained in:
parent
e888c0e66f
commit
f645b0cb75
@ -30,17 +30,20 @@ struct Node<'r, T: 'r + ?Sized> {
|
|||||||
parent: Link<'r, T>,
|
parent: Link<'r, T>,
|
||||||
}
|
}
|
||||||
|
|
||||||
struct ContextTree<'r> {
|
struct ContextTree<'r, T: 'r + ?Sized> {
|
||||||
// Not using Link so the ContextTree can own this node
|
// Not using Link so the ContextTree can own this node
|
||||||
head: Option<Node<'r, dyn OrgModeContext<'r>>>,
|
head: Option<Node<'r, T>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'r> ContextTree<'r> {
|
impl<'r> ContextTree<'r, dyn OrgModeContext<'r>> {
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
ContextTree { head: None }
|
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 {
|
let new_node = Node {
|
||||||
elem: new_elem,
|
elem: new_elem,
|
||||||
parent: self.head.as_ref(),
|
parent: self.head.as_ref(),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user