Skip to main content

union_selection

Function union_selection 

Source
pub fn union_selection(
    ast: &Ast,
    cases: &[Case],
    discriminator: i128,
    suppress_negative: bool,
) -> Result<Option<usize>, UnevaluatedLabel>
Expand description

The case a discriminator value selects, under zerodds_ast_layout::UnionLabelMatch.

suppress_negative is zerodds_ast_layout::union_negative_matches_nothing for this union’s discriminator — the crossing, asked once by the caller and passed in, so that a walk cannot ask it of the wrong type.

IDL 4.2 §7.4.1.4.4.2.4: the default: member is the one selected by any value no label names. A union with no default: and no matching label selects nothing, which is a case the corpus carries (union-default-unselected) and not an error.

§Errors

UnevaluatedLabel for a label whose constant expression the model cannot evaluate. Skipping it would turn a label that should have matched into one that matches nothing, and the walk would select a different branch — or none — and say nothing.