pub struct Variant { /* private fields */ }
Expand description

Defines an enum variant.

Implementations

Return a new enum variant with the given name.

Arguments
  • name - The name of the enum variant.
Examples
use rust_codegen::Variant;
 
let foo_variant = Variant::new("Foo");

Add a named field to the variant.

Arguments
  • name - The name of the field.
  • ty - The type of the field.
Examples
use rust_codegen::Variant;
 
let mut foo_variant = Variant::new("Foo");
foo_variant.named("Bar", "String");

Add a tuple field to the variant.

Arguments
  • ty - The type of the tuple.
Examples
use rust_codegen::Variant;
 
let mut foo_variant = Variant::new("Foo");
foo_variant.tuple("i32");

Formats the variant using the given formatter.

Arguments
  • fmt - The formatter to use.
Examples
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);

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. 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.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.