Protobuf.write_varint.go: def of bend-kit-protobuf@0.2.0.0 Import: import bend-kit-protobuf@0.2.0.0/protobuf.bend as Protobuf Lines 319-333 of bend-kit-protobuf@0.2.0.0/protobuf.bend: https://jend.leeeet.dev/read.txt?path=bend-kit-protobuf@0.2.0.0/protobuf.bend&start_line=319&end_line=333 import Base import bend-kit-bytes@0.3.3.0/bytes.bend as B def write_varint.go(fuel: Nat, done: Bool, w: Word64, out: B.Bytes, +max_size: U32) -> Result<&2, &1, Error, B.Bytes>: match fuel: case 0n: Fail{Malformed{}} case 1n+p: match done: case True{}: Word64{h, l} = w byte(out, l, max_size) case False{}: Word64{+h, +l} = w +rest = Word64.shr7(Word64{h, l}) do Result<&2, &1, Error, B.Bytes>: next : B.Bytes <- byte(out, ((l .&. 127) .|. 128 : U32), max_size) write_varint.go(p, write_varint.done(rest), rest, next, max_size) Uses (13): https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Bool https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Nat https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Result https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Result.bind https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=U32 https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=U32.and https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=U32.or https://jend.leeeet.dev/definition.txt?path=bend-kit-bytes@0.3.3.0/bytes.bend&name=Bytes https://jend.leeeet.dev/definition.txt?path=bend-kit-protobuf@0.2.0.0/protobuf.bend&name=Error https://jend.leeeet.dev/definition.txt?path=bend-kit-protobuf@0.2.0.0/protobuf.bend&name=Word64 https://jend.leeeet.dev/definition.txt?path=bend-kit-protobuf@0.2.0.0/protobuf.bend&name=Word64.shr7 https://jend.leeeet.dev/definition.txt?path=bend-kit-protobuf@0.2.0.0/protobuf.bend&name=byte https://jend.leeeet.dev/definition.txt?path=bend-kit-protobuf@0.2.0.0/protobuf.bend&name=write_varint.done