def Text.control.go
import bend-trace-context@0.2.0.0/trace_context.bend as TraceContextimport Base
2819# The offset of the first control character of `text`, counted from
2820# `offset`, unless `found` already holds one. This is a loop.
2821def Text.control.go(text: String, +offset: Nat, found: Maybe<&2, Nat>) -> Maybe<&2, Nat>:
2822 match text found:
2823 case _ Some{at}:
2824 Some{at}
2825 case SNil{} None{}:
2826 None{}
2827 case SCon{char, rest} None{}:
2828 Text.control.go(rest, 1n+offset, Bool.pick(Maybe<&2, Nat>, Text.is_control(char), Some{offset}, None{}))