def utf8_tail
import cli@0.2.0.0/cli.bend as Cliimport Base
7929# The code point acc continues to through the first more bytes of rest,
7930# each a continuation byte (80..BF); None if rest ends first or one is not.
7931def utf8_tail(rest: List<&2, U32>, more: Nat, acc: U32) -> Maybe<&2, U32>:
7932 match rest more:
7933 case Nil{} 0n: Some{acc}
7934 case Nil{} 1n+m: None{}
7935 case Con{b, t} 0n: Some{acc}
7936 case Con{+b, t} 1n+m:
7937 utf8_next(U32.is_lt((b - 128 : U32), 64),
7938 utf8_tail(t, m, (acc * 64 + (b - 128) : U32)))