Expand description
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::Scope;
let mut scope = Scope::new();
scope.new_struct("Foo")
.derive("Debug")
.field("one", "usize")
.field("two", "String");
println!("{}", scope.to_string());
Structs§
- Associated
Const - Defines an associated constant.
- Associated
Type - 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 (
use
statement). - 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.