Trait FieldsExt

Source
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§