[−][src]Crate codegen_rs
Provides a builder API for generating Rust code.
The general strategy for using the crate is as follows:
- Create a
Scope
instance. - Use the builder API to add elements to the scope.
- 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());
Structs
AssociatedType | Defines an associated type. |
Block | Defines a code block. This is used to define a function body. |
Enum | Defines an enumeration. |
Field | Defines a struct field. |
Formatter | Configures how a scope is formatted. |
Function | Defines a function. |
Impl | Defines an impl block. |
Import | Defines an import ( |
Module | Defines a module. |
Scope | Defines a scope. |
Struct | Defines a struct. |
Trait | Define a trait. |
Type | Defines a type. |
Variant | Defines an enum variant. |
Functions
fmt_bound_rhs | Format multiple generic bounds. |
fmt_bounds | Format generic bounds. |
fmt_generics | Format generics. |