def read_go
import bend-collections@1.0.0.0/src/crypto/argon2/phc.bend as Phcimport Base
240# Digits from s on top of v (d says s starts with a digit); the value and the rest.
241def read_go(s: String, +v: Nat, d: Bool) -> Got:
242 match s d:
243 case SNil{} _:
244 Got{v, SNil{}}
245 case SCon{Chr{+x}, +rest} True{}:
246 read_go(rest, Nat.add(Nat.mul(v, 10n), U32.to_nat(U32.sub(x, 48))), starts_digit(rest))
247 case SCon{c, rest} False{}:
248 Got{v, SCon{c, rest}}