Crates.io | codegen-rs |
lib.rs | codegen-rs |
version | 0.1.4 |
source | src |
created_at | 2021-01-19 14:06:06.974465 |
updated_at | 2021-01-19 14:06:06.974465 |
description | Library for generating Rust code |
homepage | https://github.com/neysofu/codegen-rs |
repository | https://github.com/neysofu/codegen-rs |
max_upload_size | |
id | 343964 |
size | 71,574 |
Provides an builder API to assist in generating Rust code.
More information about this crate can be found in the crate documentation
To use codegen-rs
, first add this to your Cargo.toml
:
[dependencies]
codegen-rs = "0.1.4"
Next, add this to your crate:
extern crate codegen_rs;
Scope
instance.Scope::to_string()
to get the generated code.For example:
use codegen_rs::Scope;
let mut scope = Scope::new();
scope.new_struct("Foo")
.derive("Debug")
.field("one", "usize")
.field("two", "String");
println!("{}", scope.to_string());
codegen-rs
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 codegen-rs
by you, shall be licensed as MIT, without any
additional terms or conditions.