Expand description
Provides a builder API for generating Rust code.
The general strategy for using the crate is as follows:
- Create a
Scopeinstance. - 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§
- 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 (
usestatement). - Defines a module.
- Defines a scope.
- Defines a struct.
- Define a trait.
- Defines a type.
- Defines an enum variant.
Functions§
- Format multiple generic bounds.
- Format generic bounds.
- Format generics.