pub struct Variant { /* private fields */ }
Expand description
Return a new enum variant with the given name.
name
- The name of the enum variant.
use rust_codegen::Variant;
let foo_variant = Variant::new("Foo");
Add a named field to the variant.
name
- The name of the field.
ty
- The type of the field.
use rust_codegen::Variant;
let mut foo_variant = Variant::new("Foo");
foo_variant.named("Bar", "String");
Add a tuple field to the variant.
ty
- The type of the tuple.
use rust_codegen::Variant;
let mut foo_variant = Variant::new("Foo");
foo_variant.tuple("i32");
Formats the variant using the given formatter.
fmt
- The formatter to use.
use rust_codegen::{Formatter,Variant};
let mut dest = String::new();
let mut fmt = Formatter::new(&mut dest);
let mut foo_variant = Variant::new("Foo");
foo_variant.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.