✓
Passing This code compiles and runs correctly.
Code
// std/rings — a proto-typed element rides the ring by value. The `{ }`
// body is the same declaration grammar a proto speaks: `name: Type`
// entries. A ring holds exactly one; the word names the element in
// diagnostics and generated units. `dequeue | some r` binds the whole
// proto — field deconstruction happens in Koru after the take.
import std/proto
import std/rings
import std/io
std/proto(Reading) {
id: u64
ts: f64
}
pub tor mk-reading { i: u64, t: f64 } -> Reading
mk-reading -> { id: i, ts: t }
std/rings:new(feed, capacity: 8) { reading: Reading }
mk-reading(i: 7, t: 2.5): r |> std/rings:enqueue(feed, v: r)
| ok |> std/rings:dequeue(feed)
| some v |> std/io:print.ln("got {{ v.id:d }} {{ v.ts:f }}")
| none |> std/io:print.ln("ERROR: empty")
| full |> std/io:print.ln("ERROR: full")
Actual
got 7 2.5
Expected output
got 7 2.5
Flows
flow ~std/proto click a branch to expand · @labels scroll to their anchor
std/proto (Reading, source: id: u64
ts: f64)
flow ~new click a branch to expand · @labels scroll to their anchor
new (feed, capacity: 8, source: reading: Reading)
flow ~mk-reading click a branch to expand · @labels scroll to their anchor
mk-reading (i: 7, t: 2.5)
Test Configuration
MUST_RUN