Skip to main content

types_compatible

Function types_compatible 

Source
pub const fn types_compatible(actual: ValueType, expected: ValueType) -> bool
Expand description

Returns true when a value of type actual can satisfy a slot or pipe that expects type expected. ValueType::Any is compatible with every concrete type in either direction; concrete types are compatible only with themselves.

Compatibility is symmetric: types_compatible(a, b) == types_compatible(b, a). The narrowing behaviour during unification (e.g. Number ∩ Any → Number) is handled by the caller (see Template::infer_types) — this function only answers the binary “is this assignment legal?” question.