Skip to main content

pystruct_sequence_data

Attribute Macro pystruct_sequence_data 

Source
#[pystruct_sequence_data]
Expand description

Attribute macro for struct sequence Data structs.

Generates field name constants, index constants, and into_tuple() method.

§Example

#[pystruct_sequence_data]
struct StructTimeData {
    pub tm_year: PyObjectRef,
    pub tm_mon: PyObjectRef,
    #[pystruct_sequence(skip)]  // optional field, not included in tuple
    pub tm_gmtoff: PyObjectRef,
}

§Options

  • try_from_object: Generate try_from_elements() method and TryFromObject impl
#[pystruct_sequence_data(try_from_object)]
struct StructTimeData { ... }