def bytewise

bend-kit-hash@0.3.0.2 · hash.bend:128

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

128# A hash that eats one byte at a time: word takes the four bytes of a word, byte one.
129def bytewise(~T: Type, ~byte: T -> @+c: U32 -> T, ~word: T -> @+c: U32 -> T, b: Bytes.Bytes, acc: T) -> Bytes.Bytes & T:
130  Bytes.Bytes{+len, buf} = b
131  bytewise.rest(~T, ~byte, len, wfrom(~T, ~word, U32.to_nat((len >> 2n : U32)), buf, 0, acc))

Uses (7)

Used by (4)