pub struct Enum { /* private fields */ }
Expand description
Returns a enum definition with the provided name.
name
- The name of the enum.
use rust_codegen::Enum;
let foo_enum = Enum::new("Foo");
Returns a reference to the enum’s type.
use rust_codegen::Enum;
let foo_enum = Enum::new("Foo");
println!("{:?}", foo_enum.ty());
Set the enum’s visibility.
vis
- The visibility of the enum.
use rust_codegen::Enum;
let mut foo_enum = Enum::new("Foo");
foo_enum.vis("pub");
Add a generic to the enum.
name
- The name of the generic.
use rust_codegen::Enum;
let mut foo_enum = Enum::new("Foo");
foo_enum.generic("T");
Add a where
bound to the enum.
name
- The name of the bound.
ty
- The type of the bound.
use rust_codegen::Enum;
let mut foo_enum = Enum::new("Foo");
foo_enum.bound("T", "Default");
Set the enum’s documentation.
docs
- The docs to set for the enum.
use rust_codegen::Enum;
let mut foo_enum = Enum::new("Foo");
foo_enum.doc("Sample Foo enum documentation");
Add a new type that the enum should derive.
name
- The name of the derive.
use rust_codegen::Enum;
let mut foo_enum = Enum::new("Foo");
foo_enum.derive("Debug");
Specify lint attribute to supress a warning or error.
allow
- The lint attribute to apply.
use rust_codegen::Enum;
let mut foo_enum = Enum::new("Foo");
foo_enum.allow("dead_code");
Specify representation.
repr
- The representation to specify.
use rust_codegen::Enum;
let mut foo_enum = Enum::new("Foo");
foo_enum.repr("C");
Push a variant to the enum, returning a mutable reference to it.
name
- The name of the variant.
use rust_codegen::Enum;
let mut foo_enum = Enum::new("Foo");
foo_enum.new_variant("FirstVariant");
Push a variant to the enum.
item
- The variant to push to the enum.
use rust_codegen::*;
let mut foo_enum = Enum::new("Foo");
let foo_enum_first_variant = Variant::new("FirstVariant");
foo_enum.push_variant(foo_enum_first_variant);
Formats the enum using the given formatter.
fmt
- The formatter to use.
use rust_codegen::*;
let mut dest = String::new();
let mut fmt = Formatter::new(&mut dest);
let foo_enum = Enum::new("Foo");
foo_enum.fmt(&mut fmt);
Performs copy-assignment from source
. Read more
Formats the value using the given formatter. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more
Returns the argument unchanged.
Calls U::from(self)
.
That is, this conversion is whatever the implementation of
From<T> for U
chooses to do.
The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
The type returned in the event of a conversion error.