deep_causality_ast
A persistent, immutable, thread-safe tree data structure for the deep_causality project.
Overview
This crate provides ConstTree<T>, a foundational Abstract Syntax Tree (AST) structure designed for efficiency and safety in concurrent environments. It is a persistent data structure, meaning that all modifications are non-destructive and return a new instance of the tree, sharing as much of the underlying data as possible with the original.
This copy-on-write behavior makes it highly efficient to pass trees around and create modified versions without incurring the cost of deep copies.
Core Features
- Persistent & Immutable: Operations that "modify" the tree are non-destructive. They return a new, modified
ConstTree, leaving the original unchanged. - Efficient Cloning:
ConstTreeis built onstd::sync::Arc. Cloning a tree is a cheap, constant-time operation that simply increments a reference count. - Thread-Safe: It is
SendandSync(ifTisSendandSync), allowing it to be safely shared across threads without locks. - Rich API: Includes a comprehensive API for construction, traversal, searching, and functional mapping.
- Multiple iteration strategies (pre-order, post-order, level-order, consuming).
- Consuming (
into_map) and non-consuming (map) mapping methods. - Monadic
joinmethod to flatten aConstTree<ConstTree<T>>.
Usage
Here is a basic example of how to create and interact with a ConstTree.
use ConstTree;
👨💻👩💻 Contribution
Contributions are welcomed especially related to documentation, example code, and fixes. If unsure where to start, just open an issue and ask.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in deep_causality by you, shall be licensed under the MIT licence, without any additional terms or conditions.
📜 Licence
This project is licensed under the MIT license.
👮️ Security
For details about security, please read the security policy.