Crates.io | codegen2 |
lib.rs | codegen2 |
version | 0.1.4 |
source | src |
created_at | 2021-11-10 08:46:15.862346 |
updated_at | 2021-11-10 08:46:15.862346 |
description | Library for generating Rust code |
homepage | https://github.com/GothAck/codegen2 |
repository | https://github.com/GothAck/codegen2 |
max_upload_size | |
id | 479554 |
size | 72,940 |
Provides an builder API to assist in generating Rust code.
More information about this crate can be found in the crate documentation
To use codegen2
, first add this to your Cargo.toml
:
[dependencies]
codegen2 = "0.1.4"
Next, add this to your crate:
extern crate codegen2;
Scope
instance.Scope::to_string()
to get the generated code.For example:
use codegen2::Scope;
let mut scope = Scope::new();
scope.new_struct("Foo")
.derive("Debug")
.field("one", "usize")
.field("two", "String");
println!("{}", scope.to_string());
codegen2
will not attempt to perform anything beyond basic formatting. For
improved formatting, the generated code can be passed to rustfmt
.
This project is licensed under the MIT license.
Unless you explicitly state otherwise, any contribution intentionally submitted
for inclusion in codegen2
by you, shall be licensed as MIT, without any
additional terms or conditions.