Expand description

Provides a builder API for generating Rust code.

The general strategy for using the crate is as follows:

  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();

    .field("one", "usize")
    .field("two", "String");

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


Defines an associated constant.
Defines an associated type.
Defines a code block. This is used to define a function body.
Defines an enumeration.
Defines a struct field.
Configures how a scope is formatted.
Defines a function.
Defines an impl block.
Defines an import (use statement).
Defines a module.
Defines a scope.
Defines a struct.
Define a trait.
Defines a type.
Defines an enum variant.


Format multiple generic bounds.
Format generic bounds.
Format generics.