Crates.io | codegen |
lib.rs | codegen |
version | 0.2.0 |
source | src |
created_at | 2017-10-31 21:40:00.566384 |
updated_at | 2022-09-19 00:04:42.80037 |
description | Library for generating Rust code |
homepage | https://github.com/carllerche/codegen |
repository | https://github.com/carllerche/codegen |
max_upload_size | |
id | 37608 |
size | 82,260 |
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
, first add this to your Cargo.toml
:
[dependencies]
codegen = "0.2.0"
Next, add this to your crate:
extern crate codegen;
Scope
instance.Scope::to_string()
to get the generated code.For example:
use codegen::Scope;
let mut scope = Scope::new();
scope.new_struct("Foo")
.derive("Debug")
.field("one", "usize")
.field("two", "String");
println!("{}", scope.to_string());
codegen
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
by you, shall be licensed as MIT, without any
additional terms or conditions.