#[derive(Options)]
{
// Attributes available to this derive:
#[system2]
}
Expand description
Derives Options for an enum, so that its variants are the options of a Choice.
Each variant must be a unit variant. The name of an option is the name of its variant in snake
case, with no r#. Its description is the doc comment of the variant, as rustdoc shows it. Two
attributes change them:
#[system2(rename = "…")]gives the name.#[system2(description = "…")]gives the description. Then the derive ignores the doc comment, so the doc comment can hold text for rustdoc only.
An option with no description sends its name only. The enum has 1 to 255 variants, and each name is different. Each error is a compile error at its variant.
§Examples
use system2::{Choice, Options, choice};
#[derive(Debug, Clone, Copy, PartialEq, Options)]
enum Team {
/// Payments, invoices, and refunds.
Billing,
/// Bugs and outages.
Engineering,
/// The team for all other tickets.
#[system2(rename = "support", description = "Each other ticket.")]
Help,
}
const TEAM: Choice<Team> = choice!("Which team must answer the ticket?", Team);