aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/ast.rs2
-rw-r--r--src/tree.rs7
2 files changed, 7 insertions, 2 deletions
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<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,