enum Color { Red, Green, Blue }compare c { matches Color::Red: ... done matches Color::Green ... done}// ERROR: Non-exhaustive enum comparison on 'Color'.// Missing variants: Color::Blue// Hint: Add an arm for each missing variant, or 'otherwise:' (or// `matches _:`) to handle the rest.With no otherwise and no unguarded _, these subjects must be covered
completely, because nothing else says what should happen to a value no arm
names:
- an enum or machine: every variant;
- a
bool: bothtrueandfalse; - an error value (
errinrecover as err run): it can be any error a callee returns, so the set can’t be listed and it always needsotherwiseor_.
A guarded arm never counts toward coverage, however complete it looks:
matches Color::Green if ready: // ready may be false, so Green is // still not coveredAn int, string or char subject is different: a compare over one may
match nothing, in which case it does nothing.
A value of a declared error type (mut e: IOError = ..., unlike the open
err) has a listable set of variants, so covering all of them is exhaustive
without otherwise: each by an unguarded variant pattern whose fields all match
anything (IOError::Denied(_, mode)). A variant whose pattern can fail
(IOError::Denied(_, 0)) is not yet covered.
Run turf --explain E093 in a terminal to read this again.