def finish.buf
import bend-kit-cbor@0.3.0.0/cbor.bend as Cborimport Base
import bend-kit-bytes@0.3.3.0/bytes.bend as Bytes
51def finish.buf(full: Bool, cap: U32, buf: Array<U32>, +k: U32, +r: U32, +word: U32) -> Array<U32>:
52 match full:
53 case True{}:
54 +grow = U32.is_eq(k, cap)
55 Bytes.flush(True{}, grow.if(grow, buf, k), k, U32.shrn(word, U32.to_nat(((4 - r) * 8 : U32))))
56 case False{}:
57 buf