Coder Social home page Coder Social logo

codegen's Introduction

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.

codegen's People

Contributors

andrewleverette avatar briansmith avatar carllerche avatar hawkw avatar luro02 avatar marcelbuesing avatar nbigaouette avatar neysofu avatar piranna avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.