def is_needless

bend-lint-rules@0.2.0.0 · language/unneeded_plus.bend:110

import bend-lint-rules@0.2.0.0/language/unneeded_plus.bend as UnneededPlus
import Base

110# Whether a `+` binder its body uses at most once (`once`) needs no `+`: not if a match takes it apart, nor if it is a
111# parameter of a definition used as a value: the type it must have can ask for the `+`.
112def is_needless(once: Bool, parameter: Bool, owner: Owner, b: U32) -> Bool:
113  match once parameter owner:
114    case True{} True{} Owner{values, target, matched}:
115      Bool.not(
116        List.contains(~String, ~String.eq, values, target)
117      )
118        && Bool.not(List.contains(~U32, ~U32.is_eq, matched, b))
119    case True{} False{} Owner{values, target, matched}:
120      Bool.not(List.contains(~U32, ~U32.is_eq, matched, b))
121    case _ _ _:
122      False{}

Uses (9)

Used by (1)