another-visitor
A crate that lets you derive visitor pattern implementations for your structs. Made because I couldn't find an existing crate supporting the exact pattern I wanted.
The general flow is inspired by how it works in ANTLR4:
- Visitor has a return type that all visit_* fns return
- Allows only implementing visit fns for some types in the tree (defaults to visiting all children)
- Allows manually visiting children if you do implement a visit fn for a type
- Allows mutation (using VisitableMut and VisitorMut)
See another-visitor/examples for more examples.
TODO
- Derive Visitable(Mut) for more types (only basic structs and enums are supported)
- Visitable(Mut) impls for more std containers
- Good error messages in proc macros
- Documentation
- Publish to crates.io
This project is a WIP, if you have suggestions for changes or new features, please open an issue!
Licenses
Licensed under either of
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.
Contribution
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.