8000 print_items_with: print a burst with the caller's own time prefix by 0-jake-0 · Pull Request #1048 · wingfoil-io/wingfoil · GitHub
[go: up one dir, main page]

Skip to content

print_items_with: print a burst with the caller's own time prefix - #1048

Merged
0-jake-0 merged 1 commit into
mainfrom
claude/exciting-keller-nn54hx
Oct 17, 2026
Merged

0-jake-0 merged 1 commit into
mainfrom
claude/exciting-keller-nn54hx

Conversation

@0-jake-0
Copy link
Copy Markdown
Contributor

What this changes

  • New op PrintItemsWith / StreamOps::print_items_with(prefix). Each item prints as {prefix} {item}, where prefix is whatever the closure makes of the tick's engine time (Ctx::time, not elapsed). The closure is called once per tick, not once per item. Works compiled and interpreted.
  • Display for TradingState.
  • exchange_day's three hand-written with_time().for_each printers become three print_items_with lines over its clock.

Why

A follow-up to #1047. exchange_day was the one example still writing its own printers, because print_items prints elapsed seconds and this example reads as a trading day (day 1 10:01). The time format is now the caller's choice, so the example no longer needs its own printers.

How it was verified

  • cargo fmt --all
  • cargo lint. cargo lint-all didn't run here: Aeron's native build and protoc fail in the sandbox. I ran cargo clippy -p wingfoil --features execution-testing --all-targets -D warnings instead.
  • cargo test -p wingfoil --features execution-testing, plus the --doc tests
  • New behaviour is covered by a test asserting values and tick times. print_items_with_passes_through_and_hands_the_prefix_engine_time checks the pass-through, and that the prefix is called once per tick with the engine time (under HistoricalFrom(100), so engine time and elapsed differ). op_completeness::surface_lifecycle exercises it compiled.

I re-ran exchange_day's README output and pasted it in. It prints the same lines in the same order. The only change is that state lines read trading Halted where they read [Halted].

Notes for the reviewer

  • Why the closure builds the whole prefix: it builds the label as well as the time, so the op needs one closure and no label argument. A (label, closure) tuple config has no precedent with a closure inside it, and the compiled path would have had to learn it.
  • No Python binding. It's the same reason as print_items, and here the config is also a Rust closure.

Generated by Claude Code

exchange_day kept three hand-written with_time().for_each printers because
print_items prints elapsed seconds and the example reads as a trading day.
Add `StreamOps::print_items_with(prefix)` (op `PrintItemsWith`): each item
prints as `{prefix} {item}`, the prefix whatever the closure makes of the
tick's engine time, called once per tick. Dual-mode, in op_completeness.

`TradingState` gains `Display`, and exchange_day's three printers become
three `print_items_with` lines over its `clock`. Its output keeps the same
lines in the same order; the state lines now read `trading Halted` where
they read `[Halted]`.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017dgcqDybTW43hgVVh63RK2
@0-jake-0
0-jake-0 merged commit 1b252b1 into main Oct 17, 2026
9 checks passed
@0-jake-0
0-jake-0 deleted the claude/exciting-keller-nn54hx branch October 17, 2026 15:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

0