9 releases

0.0.9 Nov 13, 2024
0.0.7 May 31, 2024
0.0.5 Jan 3, 2024
0.0.4 Dec 20, 2023
0.0.1 Feb 25, 2023

#1573 in Procedural macros

Download history 140/week @ 2024-08-26 7/week @ 2024-09-02 10/week @ 2024-09-09 26/week @ 2024-09-16 32/week @ 2024-09-23 14/week @ 2024-09-30 5/week @ 2024-10-07 9/week @ 2024-10-14 5/week @ 2024-10-28 9/week @ 2024-11-04 130/week @ 2024-11-11 23/week @ 2024-11-18 10/week @ 2024-11-25 13/week @ 2024-12-02 47/week @ 2024-12-09

98 downloads per month
Used in 4 crates (via ezno-parser)

MIT license

8KB
139 lines

visiting-proc-macro lines of code

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.

Usage

use visitable_derive::Visitable;

#[derive(Visitable)]
struct MyAstNode {
	...
}

Attributes

visit_self

Will 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_field

Skips visiting the field. Used if type does not implement Visitable

#[derive(Visitable)]
struct MyAstNode {
	#[visit_skip_field]
	a: String
}

Dependencies

~43KB