pub trait FieldsExt {
    // Required methods
    fn is_unit(&self) -> bool;
    fn is_named(&self) -> bool;
    fn is_tuple(&self) -> bool;
    fn construction_form(&self) -> TokenStream;
}
Expand description

Functions to make it ergonomic to work with Fields.

Required Methods§

source

fn is_unit(&self) -> bool

Returns true if the Fields is for a unit struct.

source

fn is_named(&self) -> bool

Returns true if the Fields is for a struct with named fields.

source

fn is_tuple(&self) -> bool

Returns true if the Fields is for a struct with unnamed fields.

source

fn construction_form(&self) -> TokenStream

Returns a token stream of the construction form of the fields.

For unit fields, this returns an empty token stream.

  • Tuple fields: (_0, _1,)
  • Named fields: { field_0, field_1 }
Examples

Implementations on Foreign Types§

source§

impl FieldsExt for Fields

Implementors§