Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/timsueberkrueb/visit
Automatically generate Rust code for the Visitor pattern
https://github.com/timsueberkrueb/visit
proc-macro rust visitor-pattern
Last synced: about 1 month ago
JSON representation
Automatically generate Rust code for the Visitor pattern
- Host: GitHub
- URL: https://github.com/timsueberkrueb/visit
- Owner: timsueberkrueb
- License: apache-2.0
- Created: 2019-02-16T15:23:22.000Z (almost 6 years ago)
- Default Branch: develop
- Last Pushed: 2019-04-23T18:47:59.000Z (over 5 years ago)
- Last Synced: 2024-08-09T21:14:48.920Z (5 months ago)
- Topics: proc-macro, rust, visitor-pattern
- Language: Rust
- Homepage: https://docs.rs/visit
- Size: 65.4 KB
- Stars: 6
- Watchers: 3
- Forks: 0
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE-APACHE
Awesome Lists containing this project
README
# visit
Automatically generate code for the [Visitor pattern](https://en.wikipedia.org/wiki/Visitor_pattern).
## Usage
```rust
visit! {
// Automatically generates `Visitor` and `AcceptVisitor` traits
// The `Visitor` trait will contain `visit_` functions for all items inside of the macro call.
// The `AcceptVisitor` trait will be implemented automatically for all items.
#![visitor(name = "Visitor")]struct Bar {
a: Child,
b: Child,
}struct Child {}
}struct MyVisitor;
impl Visitor for MyVisitor {
fn visit_child(&mut self, _child: &Child) {
// Do something cool
}
}
```## License
visit is licensed under either of the following licenses, at your option:
* [Apache License Version 2.0](LICENSE-APACHE)
* [MIT License](LICENSE-MIT)