Skip to main content

system2_shared/
choice.rs

1//! The limits and the messages of the options of a Choice.
2
3/// The most options that a Choice can have.
4pub const MAX_OPTIONS: usize = 255;
5
6/// Returns the message for a Choice with no options, or with too many.
7#[must_use]
8pub fn count_message(count: usize) -> String {
9    format!("a Choice must have 1 to {MAX_OPTIONS} options, not {count}")
10}
11
12/// Returns the message for two options with the same name.
13#[must_use]
14pub fn duplicate_message(name: &str) -> String {
15    format!("each option must have a different name, but two options have the name `{name}`")
16}