For AI agents: the complete documentation index is available at /llms.txt, the full documentation bundle is available at /llms-full.txt, and this page is available as Markdown at /packs/languages/rust/conditionals.md.
Quick start

Conditionals

Keep successful paths readable and make closed alternatives explicit.

Branching

Why

An exhaustive match makes a newly added enum variant visible to callers at compile time.

Rules

  • MUST return early from invalid preconditions. [review]
  • MUST match closed domain enums exhaustively. [review]
  • MUST avoid wildcard arms that hide an unhandled repository-owned enum variant. [review]
  • MUST use if let for a genuinely partial match and match when every alternative matters. [review]
  • MUST consume the narrowed variant rather than recover it with unchecked extraction. [review]
  • MUST avoid nested conditionals around the successful operation. [review]

[review]

The compiler establishes exhaustive matching. Review distinguishes deliberate partial handling from missing cases.

Enforcement

The compiler establishes exhaustive matching. Review distinguishes deliberate partial handling from missing cases.