A Rust library providing a builder API to generate Rust code.
Provides an builder API to assist in generating Rust code.
More information about this crate can be found in the crate documentation
codegen, first add this to your
[dependencies] codegen = "0.1.3"
Next, add this to your crate:
extern crate codegen;
1) Create a
Scopeinstance. 2) Use the builder API to add elements to the scope. 3) Call
Scope::to_string()to get the generated code.
let mut scope = Scope::new();
scope.new_struct("Foo") .derive("Debug") .field("one", "usize") .field("two", "String");
codegenwill not attempt to perform anything beyond basic formatting. For improved formatting, the generated code can be passed to
This project is licensed under the MIT license.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in
codegenby you, shall be licensed as MIT, without any additional terms or conditions.