def next

bend-collections@1.0.0.0 · src/math/random/chacha8.bend:77

import bend-collections@1.0.0.0/src/math/random/chacha8.bend as Chacha8
import Base
import bend-collections@1.0.0.0/src/math/u64.bend as W

77# the next 64-bit output (a refill always yields a nonempty buffer)
78def next(g: ChaCha8) -> W.U64 & ChaCha8:
79  match g:
80    case C{+k, p, buf}:
81      match buf:
82        case Con{x, rest}:
83          (x, C{k, p, rest})
84        case Nil{}:
85          pop(refill(k, p))

Uses (7)

Used by (3)