Skip to content
This repository was archived by the owner on Mar 11, 2025. It is now read-only.

Suggestion: allow deriving Template on enums #666

@tema3210

Description

@tema3210

Restrictions: Each enum variant should be tuple like with exactly one variant, wrapped type of each variant should implement Template
Semantics: While useless for top level pages(??), it may be handy for component templates:

  • we make dispatch for template components automatic;
  • their enumeration easy
  • when one wants to render one of many variants of template, currently others still need to be initialized resulting in waste of memory as well as the need to fill unused variants somehow (hello Option and template level matching)

Consider:

#[derive(Template)]
enum OrderStatus {
  Arrived(ArrivedOrder),
  Delivery(DeviveryOrder),
  PendingConfirmation(ConfirmOrder)
}

Isn't that nice?

Edit: removed pointless annotation

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions