def Spans.last
import bend-lint-rules@0.2.0.0/lib/text/main.bend as BendLintRulesimport Base
175# The end of the last span of `t` (by start, then end) that starts before `e`, or `found`. `before` says whether the
176# root's does. Its end is the furthest of theirs, as ends rise with starts.
177def Spans.last(t: Spans, +e: U32, found: Maybe<&2, U32>, before: Bool) -> Maybe<&2, U32>:
178 match t before:
179 case SLeaf{} _:
180 found
181 case SNode{h, l, x, y, +r} True{}:
182 Spans.last(r, e, Some{y}, Spans.starts_before(r, e))
183 case SNode{h, +l, x, y, r} False{}:
184 Spans.last(l, e, found, Spans.starts_before(l, e))