score!() { /* proc-macro */ }Expand description
Makes a Score that the compiler checks.
The instructions come first, in a form that noul! takes. The levels come second, from the
lowest to the highest:
- A type that derives
Levels. The answer gives a variant. - An array of levels as text. The answer gives the text.
- An array of
(level, value). The answer gives the value.
Each level is a string literal, so two equal levels are a compile error. Each value is a
constant expression of any type, and it is not sent. A Score has 1 to 10 levels. For levels
from data, use Score::new or Score::with_values.
ยงExamples
use system2::{Levels, Score, score};
#[derive(Debug, Clone, Copy, PartialEq, Levels)]
enum Urgency {
Low,
Medium,
High,
}
const URGENCY: Score<Urgency> = score!("How urgent is the ticket?", Urgency);
const SIZE: Score<&str> = score!("How big is the fix?", ["A line.", "A file.", "A module."]);
const DAYS: Score<u32> = score!("How long does the fix take?", [("A day.", 1), ("A week.", 5)]);