Skip to content

Commit

Permalink
[doc] explain how case clauses with multiple selectors are supported
Browse files Browse the repository at this point in the history
  • Loading branch information
teoxoy authored and jimblandy committed Dec 9, 2022
1 parent 833ce7d commit e9f817d
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1466,6 +1466,22 @@ pub enum Statement {
reject: Block,
},
/// Conditionally executes one of multiple blocks, based on the value of the selector.
///
/// Each case must have a distinct [`value`], exactly one of which must be
/// [`Default`]. The `Default` may appear at any position, and covers all
/// values not explicitly appearing in other cases. A `Default` appearing in
/// the midst of the list of cases does not shadow the cases that follow.
///
/// Some backend languages don't support fallthrough (HLSL due to FXC,
/// WGSL), and may translate fallthrough cases in the IR by duplicating
/// code. However, all backend languages do support cases selected by
/// multiple values, like `case 1: case 2: case 3: { ... }`. This is
/// represented in the IR as a series of fallthrough cases with empty
/// bodies, except for the last.
///
/// [`value`]: SwitchCase::value
/// [`body`]: SwitchCase::body
/// [`Default`]: SwitchValue::Default
Switch {
selector: Handle<Expression>, //int
cases: Vec<SwitchCase>,
Expand Down

0 comments on commit e9f817d

Please sign in to comment.