Description ππ
The crate docs should be considered the only source of truth for this crate usage.
rust_writer is a crate designed to simplify meta programming in Rustβbut in a different way than the typical procedural macro crates (such as syn, quote, and proc_macro2).
While those crates excel at writing procedural macros, rust_writer leverages their capabilities to modify Rust source files. This makes it ideal for tasks that require in-place source code modifications rather than merely generating new code visible only to the compiler.
The crate is divided into two modules: the preserver module and the ast module. Although these modules can be used separately and even for purposes other than the crate's primary objective, using them together unlocks the full potential of the crate.
- The preserver module ensures that the original structure of the source code is maintained when it is parsed into an AST.
- The ast module provides various tools to simplify AST interactions, allowing precise modifications exactly where needed.
For further details, please refer to the individual module documentation. A complete example is often the best way to illustrate the functionality:
use quote;
use ;
use ;
use TestBuilder;
// A mutator defined with the given implementors.
;
// In this example, complete file can be found at https://github.com/tsenovilla/rust_writer/blob/main/test_builder/sample_files/complete_file.rs,
// while expanded_file can be found at https://github.com/tsenovilla/rust_writer/blob/main/test_builder/sample_files/expanded_file.rs
default
.with_complete_file
.with_expanded_file
.execute;
Contributing π€π
Any contribution is more than welcome! π€π¦Ύ Just open a PR with your changes and it'll be considered πΈ