def uint.if

bend-kit-bytes@0.3.3.0 · bytes.bend:176

import bend-kit-bytes@0.3.3.0/bytes.bend as Bytes
import Base

176# Big-endian reads forward from i; little-endian reads back from the last byte.
177def uint.if(ok: Bool, +len: U32, buf: Array<U32>, +i: U32, +n: U32, +be: Bool) -> Bytes & Maybe<&2, U32>:
178  match ok:
179    case True{}:
180      +j = Bool.pick(U32, be, i, (i + n - 1 : U32))
181      get.some(len, uint.go(U32.to_nat(n), peek(buf, j), j, be, 0))
182    case False{}:
183      (Bytes{len, buf}, None{})

Uses (14)

Used by (1)