#[non_exhaustive]pub struct Choice<'a> {
pub value: &'a str,
pub label: &'a str,
pub unavailable: Option<&'a str>,
pub detail: Option<&'a str>,
}Expand description
One option offered by a field FieldKind::offers_options accepts.
Two strings, because the submitted value and the read label are different
facts and every renderer that has tried to collapse them has had to
un-collapse them later. makeover-webview invented this shape writing its
form emitter and it is taken here unchanged; moving it down rather than
re-deriving it is the point, since the second and third renderers were each
going to arrive at a near-miss of it.
#[non_exhaustive] as of 0.28.0, which every other type here that a
renderer matches or builds has carried for releases. It was the omission
that made unavailable a breaking change across 40
literal sites in six repos, and it arrives with that member so the price is
paid once and never again.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.value: &'a strWhat is submitted.
label: &'a strWhat is read.
Why it cannot be picked right now, when it cannot.
One member rather than an available: bool beside a reason, and the
conflation is the point: an option greyed out with no explanation is a
dead end the user cannot act on, and it is exactly the state the app
that found this gap had to patch by hand with a line of prose under the
control. Making the reason mandatory means the description cannot say
the useless half.
The option stays in the list. Dropping it is what an app does today, and it costs the user the knowledge that the thing exists at all — audiofiles’ multi-sample mode appears on its own once a second sample is dropped, so a user who never sees it never learns what to drop.
Not Field::error, and not Field::hint. An error is about the
answer and a hint is standing help for the whole question; this is about
one option among several, which is the level neither of those reaches.
Not disabled-the-state. State::Disabled is about a whole field
refusing to answer. This says the field is live and one of its answers
is not available yet, which is a different sentence and the reason the
tone rule matters here: the other options are still usable.
Added 0.28.0, from audiofiles’ instrument mode selector (e761833e).
detail: Option<&'a str>The line under the label that says what picking this means.
5e21dcfc, measured 2026-08-29. A choice between three plans is a
choice nobody can make from three names, and until this existed the
description had nowhere to put the sentence that made it makeable. What
the corpus did instead is the tell: four of the six measured sites fold
it into the label — <strong>Public</strong>: Anyone can see this repository in MNW’s git settings, the same shape in its project-basics
AI tier and its cart’s currency conversion, and Mislabeled (wrong AI tier or category) in its report modal. The described screens do it too,
in miniature: Every 15 minutes (recommended), Reference samples in place (loose-files mode). One fact, six spellings, no member.
§Where it goes is the host’s, and the rule already exists
This is unavailable’s question met a third time
and it takes the same answer, which is the strongest evidence one member
is right rather than two. A radio group has room and gives the line its
own element beside the label. A <select>’s option takes no elements,
no second line and no title a keyboard reaches, so the line runs into
the option’s own text — exactly as a precondition does, and as a theme’s
contrast badge does in brackets. A terminal has rows and puts it on one
under the option.
§Not a price, and that is a measurement rather than a preference
The site that asked for this is MNW’s fee calculator, whose tier cards
carry a name, a price and a description, so a second member for the
price was on the table. It loses on the count: the tree’s other three
priced tier lists — project.html, project_paywall.html,
index.html — are not option lists at all. Each card carries its own
submit, which makes it a region with a heading, a fact and an act, and
it is sayable already. So a price member would have exactly one
consumer, and it would mean this crate growing a money type it does not
have: Unit is a time axis, and every amount in the described tree is
text.
The price therefore leads the line: $24/mo. 2GB/file, 100GB total. Fits audio, plugins, binaries. What would reopen it is a second
priced option list, not a judgement about how that reads.
§What it is not
Not unavailable, which says the option cannot be
picked. This says what it means to pick it, and the two are drawn
together on an option that carries both: the description that says a
tier is out of stock and what the tier is has said two things.
Not Field::hint, which is standing help for the whole question, and
not markup. One line of plain text, for Candidate::detail’s reason:
an option list is a place a renderer lays out, and a description that
put a block in one would be handing every host a layout problem for the
benefit of one.
Added 0.39.0.
Implementations§
Source§impl<'a> Choice<'a>
impl<'a> Choice<'a>
Sourcepub const fn new(value: &'a str, label: &'a str) -> Self
pub const fn new(value: &'a str, label: &'a str) -> Self
An option that submits one string and reads as another.
A constructor rather than a literal, which is what #[non_exhaustive]
costs and buys: outside this crate the struct cannot be built by naming
its members, so every call site goes through here and the next member
added breaks none of them.
Sourcepub const fn unless(self, reason: &'a str) -> Self
pub const fn unless(self, reason: &'a str) -> Self
The same option, not pickable yet, and why.
Builder-shaped because the reason is the rare case: 39 of the 40 option sites measured across the tree do not have one.