Need help with codegen?
Click the “chat” button below for chat support from the developer who created it, or find similar developers for support.

About the developer

carllerche
163 Stars 44 Forks MIT License 42 Commits 12 Opened issues

Description

A Rust library providing a builder API to generate Rust code.

Services available

!
?

Need anything else?

Contributors list

# 357,955
Rust
kde
Homebre...
gzip
14 commits
# 15,075
Rust
tokio
rust-bi...
unix
7 commits
# 16,077
Rust
rust-la...
linkerd
Kuberne...
2 commits
# 207,539
Rust
spotify
spotify...
Haskell
2 commits
# 25,014
Rust
sed
Kuberne...
dynamic...
2 commits
# 190,688
Rust
Shell
rust-la...
webasse...
2 commits
# 15,246
JavaScr...
C++
webrtc
React N...
1 commit

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

codegen
, first add this to your
Cargo.toml
:
[dependencies]
codegen = "0.1.3"

Next, add this to your crate:

extern crate codegen;

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

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.