codegen2

Crates.iocodegen2
lib.rscodegen2
version0.1.4
sourcesrc
created_at2021-11-10 08:46:15.862346
updated_at2021-11-10 08:46:15.862346
descriptionLibrary for generating Rust code
homepagehttps://github.com/GothAck/codegen2
repositoryhttps://github.com/GothAck/codegen2
max_upload_size
id479554
size72,940
Greg "GothAck" Miell (GothAck)

documentation

https://docs.rs/codegen2/0.1.4/codegen2

README

Codegen

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 codegen2, first add this to your Cargo.toml:

[dependencies]
codegen2 = "0.1.4"

Next, add this to your crate:

extern crate codegen2;

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 codegen2::Scope;

let mut scope = Scope::new();

scope.new_struct("Foo")
    .derive("Debug")
    .field("one", "usize")
    .field("two", "String");

println!("{}", scope.to_string());

Non-goals

codegen2 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 codegen2 by you, shall be licensed as MIT, without any additional terms or conditions.

Commit count: 47

cargo fmt