Trait VariantInfo

Source
pub trait VariantInfo<F: FieldInfo> {
    // Required methods
    fn ident(&self) -> &Ident;
    fn discriminant(&self) -> &Option<Expr>;
    fn fields(&self) -> &Fields<F>;

    // Provided method
    fn discriminant_expr(&self) -> TokenStream { ... }
}
Expand description

Trait to retrieve variants’ properties

Required Methods§

Source

fn ident(&self) -> &Ident

Retrieves the identifier of the passed-in variant

Source

fn discriminant(&self) -> &Option<Expr>

Retrieves the variant discriminant (if any). For a variant such as Example = 2, the 2

Source

fn fields(&self) -> &Fields<F>

Retrieves the fields associated with the variant

Provided Methods§

Source

fn discriminant_expr(&self) -> TokenStream

Retrieves the discriminant expr, if any (= 3)

Implementors§