From 6017d62db7600af491592e4f0d78611f33dc6b5e Mon Sep 17 00:00:00 2001 From: JJ Date: Fri, 27 Oct 2023 00:51:37 -0700 Subject: minor updates --- src/ast.rs | 2 +- src/tree.rs | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/ast.rs b/src/ast.rs index 71daa9b..e55b473 100644 --- a/src/ast.rs +++ b/src/ast.rs @@ -63,7 +63,7 @@ pub enum Binding { kind: Option, value: Box }, - Func { + FuncDecl { public: bool, effect: Option, id: Id, diff --git a/src/tree.rs b/src/tree.rs index 02dc749..8e2e1d0 100644 --- a/src/tree.rs +++ b/src/tree.rs @@ -1,4 +1,4 @@ -/// A simple append-only tree data structure. Represented as a Vec. +/// A simple flat append-only tree data structure. Represented as a Vec. pub struct Tree(Vec>); /// The associated Node to the Tree. @@ -12,11 +12,16 @@ pub struct Node { data: T } +/// Nodes themselves are not held onto and used, instead we use a NodeId, +/// only valid in the context of a particular Tree. There is not a great +/// way to enforce this validity that I know of, unfortunately. #[derive(Copy, Clone)] pub struct NodeId(usize); impl Tree { /// Create a new Tree with a root element. + /// You should only make one Tree in any given context. + /// Otherwise there are safety risks with using the wrong NodeId for a Tree. pub fn new(data: T) -> Tree { Tree(vec![Node { parent: None, previous_sibling: None, -- cgit v1.2.3-70-g09d2