std/sys/target
What this build is for — the target, as two values a program can
read.target::os and target::arch are constants the compiler substitutes
while it lowers: the scrutinee of a match over one is a literal
variant by the time any pass sees it, so the comparison chain has a
known answer and the backend keeps one arm. They are the value-level
half of a pair:
• @target(os = windows) on a declaration means the declaration
does not exist on any other target, so its body may call an API
no other target has. That is the tool for code that could not
typecheck elsewhere.
• match target::os chooses a value, and every arm typechecks on
every target. That is the tool for a separator, a default name, a
size — the things that differ without the surrounding code
differing.
Neither replaces the other, and the difference is exactly what keeps
the second from becoming a cfg-style expression: an arm that only
compiles somewhere would make "does this project have a target it
fails to serve" a question you can only answer by building for all of
them.
The variants are the axes' whole value set — the same closed lists@target(os = …) accepts — so a match over one is exhaustive
without a _ arm, and a spelling no target has is a compile error
rather than an arm that is quietly never taken.