codegen-rs 0.1.4

Library for generating Rust code
Documentation
  • Coverage
  • 100%
    25 out of 25 items documented1 out of 1 items with examples
  • Size
  • Source code size: 71.85 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 6.79 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Links
  • Homepage
  • neysofu/codegen-rs
    2 2 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • neysofu

Codegen-rs

Provides an builder API to assist in generating Rust code.

Build Status

More information about this crate can be found in the crate documentation

Installation

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;

Usage

  1. Create a Scope instance.
  2. Use the builder API to add elements to the scope.
  3. Call 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());

Non-goals

codegen-rs will not attempt to perform anything beyond basic formatting. For improved formatting, the generated code can be passed to rustfmt.

License

This project is licensed under the MIT license.

Contribution

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.