MCPcopy Create free account
hub / github.com/Schwenger/RustTyC / meet

Method meet

examples/parametrized_function.rs:38–55  ·  view source on GitHub ↗
(lhs: Partial<Self>, rhs: Partial<Self>)

Source from the content-addressed store, hash-verified

36 }
37
38 fn meet(lhs: Partial<Self>, rhs: Partial<Self>) -> Result<Partial<Self>, Self::Err> {
39 use Variant::*;
40 assert_eq!(lhs.least_arity, 0, "spurious child");
41 assert_eq!(rhs.least_arity, 0, "spurious child");
42 let variant = match (lhs.variant, rhs.variant) {
43 (Any, other) | (other, Any) => Ok(other),
44 (Integer(l), Integer(r)) => Ok(Integer(max(r, l))),
45 (Fixed(li, lf), Fixed(ri, rf)) => Ok(Fixed(max(li, ri), max(lf, rf))),
46 (Fixed(i, f), Integer(u)) | (Integer(u), Fixed(i, f)) if f == 0 => Ok(Integer(max(i, u))),
47 (Fixed(i, f), Integer(u)) | (Integer(u), Fixed(i, f)) => Ok(Fixed(max(i, u), f)),
48 (Bool, Bool) => Ok(Bool),
49 (Bool, _) | (_, Bool) => Err("bool can only be combined with bool"),
50 (Numeric, Integer(w)) | (Integer(w), Numeric) => Ok(Integer(w)),
51 (Numeric, Fixed(i, f)) | (Fixed(i, f), Numeric) => Ok(Fixed(i, f)),
52 (Numeric, Numeric) => Ok(Numeric),
53 }?;
54 Ok(Partial { variant, least_arity: 0 })
55 }
56
57 fn arity(&self) -> Arity {
58 Arity::Fixed(0)

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected