| Crates.io | ezno-parser-visitable-derive |
| lib.rs | ezno-parser-visitable-derive |
| version | 0.0.9 |
| created_at | 2023-02-25 17:39:44.250577+00 |
| updated_at | 2024-11-13 19:50:40.370135+00 |
| description | Derives 'Visitable' trait for Ezno AST |
| homepage | |
| repository | https://github.com/kaleidawave/ezno |
| max_upload_size | |
| id | 794454 |
| size | 7,796 |
A package which generates mutable and immutable visiting implementations for AST nodes.
A visitor is a implementor a trait of which the a function is called of a each node.
This module is specific for the parser module and contains the ability to extend with data.
use visitable_derive::Visitable;
#[derive(Visitable)]
struct MyAstNode {
...
}
visit_selfWill visit all fields first then self
#[derive(Visitable)]
#[visit_self]
struct MyAstNode {
...
}
Options:
also_visit_first_if
Will visit self additionally before if predicate is true#[derive(Visitable)]
#[visit_self(also_visit_first_if="self.predicate()"]
struct MyAstNode {
...
}
impl MyAstNode {
fn predicate(&self) -> bool {
...
}
}
visit_skip_fieldSkips visiting the field. Used if type does not implement Visitable
#[derive(Visitable)]
struct MyAstNode {
#[visit_skip_field]
a: String
}