Skip to main content

pattern_matches

Function pattern_matches 

Source
pub fn pattern_matches(
    pattern: &Pattern,
    value: &Value,
    bindings: &mut Vec<(String, Value)>,
    resolver: TypeResolveFn<'_>,
) -> bool
Expand description

The core pattern matcher. Re-exported so engines beyond the tree-walker (the bytecode VM, the AOT runtime) can apply the same structural rules without re-implementing them. Attempt to match pattern against value. On success, appends any captured (name, Value) bindings to bindings and returns true; on failure, returns false and leaves bindings in an undefined state — it’s the caller’s responsibility to discard it.

resolver is consulted whenever a pattern names a user type (Pattern::Struct or Pattern::EnumVariant) so the matcher can compare the value’s full identity (module_path, type_name) against the source-level reference.

Exported so other engines (the bytecode VM, AOT transpiler) can run the exact same structural matcher as the tree-walker without re-implementing the rules.