def close.drain
import bend-kit-runner@0.13.0.1/runner.bend as Runnerimport Base
1753# Answers each ask left in the closed inbox with a failure. fuel bounds the messages it reads.
1754def close.drain(-A: Data, fuel: Nat, +ib: Chan(Msg<A>)) -> IO(Unit):
1755 match fuel:
1756 case 0n:
1757 IO.pure(Unit, Unit{})
1758 case 1n+n:
1759 do IO<Unit>:
1760 x : Poll<&1, &1, Maybe<&1, Msg<A>>, Unit> <- Chan.try_recv(Msg<A>, ib, 0)
1761 close.polled(A, x, (u => close.drain(A, n, ib)))