diff options
author | JJ | 2023-10-27 07:51:37 +0000 |
---|---|---|
committer | JJ | 2023-10-27 07:51:37 +0000 |
commit | 6017d62db7600af491592e4f0d78611f33dc6b5e (patch) | |
tree | c2f42e4264692f92b0eded551617bf8bd8b1c948 /src | |
parent | 2ea4fd4c09ad71c4ac648cf3645426476dd7521f (diff) |
minor updates
Diffstat (limited to 'src')
-rw-r--r-- | src/ast.rs | 2 | ||||
-rw-r--r-- | src/tree.rs | 7 |
2 files changed, 7 insertions, 2 deletions
@@ -63,7 +63,7 @@ pub enum Binding { kind: Option<Type>, value: Box<Expr> }, - Func { + FuncDecl { public: bool, effect: Option<Id>, 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<T>(Vec<Node<T>>); /// The associated Node to the Tree. @@ -12,11 +12,16 @@ pub struct Node<T> { 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<T> Tree<T> { /// 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<T> { Tree(vec![Node { parent: None, previous_sibling: None, |