Skip to main content

EnumValueKpType

Type Alias EnumValueKpType 

Source
pub type EnumValueKpType<'a, Enum, Payload> = EnumKp<Enum, Payload, &'a Enum, Payload, &'a mut Enum, Payload, for<'b> fn(&'b Enum) -> Option<Payload>, for<'b> fn(&'b mut Enum) -> Option<Payload>, fn(Payload) -> Enum>;
Expand description

Casepath whose payload is extracted by value (cloned) rather than by reference.

Multi-field enum variants (e.g. Card(String, String) or Wallet { id, balance }) cannot be borrowed as a single value the way single-field variants can, because their associated values are stored as separate fields rather than one contiguous payload. This alias models such cases the way Swift’s CasePaths does: extraction yields an owned payload tuple (a clone) and embedding reconstructs the variant from that tuple.

Payload is typically a tuple of the variant’s field types and must be Clone.

Aliased Type§

pub struct EnumValueKpType<'a, Enum, Payload> { /* private fields */ }