mirror of
https://github.com/gfx-rs/wgpu.git
synced 2026-04-22 03:02:01 -04:00
[doc] explain how case clauses with multiple selectors are supported
This commit is contained in:
16
src/lib.rs
16
src/lib.rs
@@ -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>,
|
||||
|
||||
Reference in New Issue
Block a user