Skip to main content

Module struct_enum_dispatch

Module struct_enum_dispatch 

Source
Expand description

Dispatch #[miniextendr] on structs and enums to the appropriate derive helpers.

This module handles #[miniextendr] when applied to structs or enums (not functions, impl blocks, or traits). It dispatches to the correct derive helper based on:

  • Field count (1-field โ†’ ALTREP by default, multi-field โ†’ ExternalPtr by default)
  • Explicit mode attributes (list, dataframe, externalptr, match_arg, factor)
  • Preference markers (prefer = "...")

ยงDisambiguation table

SyntaxResult
#[miniextendr] on 1-field structALTREP (backwards compat)
#[miniextendr(externalptr)] on 1-field structExternalPtr
#[miniextendr(list)] on 1-field structList conversion
#[miniextendr(class = "...", base = "...")] on 1-field structALTREP (explicit)
#[miniextendr] on multi-field structExternalPtr
#[miniextendr(list)] on multi-field structIntoList + TryFromList + PreferList
#[miniextendr(dataframe)] on multi-field structDataFrameRow + PreferDataFrame
#[miniextendr(prefer = "...")] on structPrefer* marker
#[miniextendr] on fieldless enumRFactor
#[miniextendr(match_arg)] on fieldless enumMatchArg

Structsยง

StructEnumAttrs ๐Ÿ”’
Parsed attributes for #[miniextendr] on structs/enums.

Functionsยง

expand_enum ๐Ÿ”’
Dispatches #[miniextendr] on a fieldless enum to the correct derive path.
expand_struct ๐Ÿ”’
Dispatches #[miniextendr] on a struct to the correct derive path.
expand_struct_or_enum
Main dispatch entry point for #[miniextendr] on a struct or enum.
field_count ๐Ÿ”’
Returns the number of fields on a struct (named, unnamed, or unit).
is_fieldless_enum ๐Ÿ”’
Returns true if every variant of the enum is a unit variant (no fields).
parse_attrs ๐Ÿ”’
Parses the attribute arguments of #[miniextendr(...)] when applied to a struct or enum.
strip_miniextendr_attrs ๐Ÿ”’
Strip #[miniextendr(...)] attributes from a DeriveInput.