Repository navigation
print_items_with: print a burst with the caller's own time prefix - #1048
Merged
Merged
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this changes
PrintItemsWith/StreamOps::print_items_with(prefix). Each item prints as{prefix} {item}, whereprefixis 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.DisplayforTradingState.exchange_day's three hand-writtenwith_time().for_eachprinters become threeprint_items_withlines over itsclock.Why
A follow-up to #1047.
exchange_daywas the one example still writing its own printers, becauseprint_itemsprints 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 --allcargo lint.cargo lint-alldidn't run here: Aeron's native build andprotocfail in the sandbox. I rancargo clippy -p wingfoil --features execution-testing --all-targets -D warningsinstead.cargo test -p wingfoil --features execution-testing, plus the--doctestsprint_items_with_passes_through_and_hands_the_prefix_engine_timechecks the pass-through, and that the prefix is called once per tick with the engine time (underHistoricalFrom(100), so engine time and elapsed differ).op_completeness::surface_lifecycleexercises 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 readtrading Haltedwhere they read[Halted].Notes for the reviewer
(label, closure)tuple config has no precedent with a closure inside it, and the compiled path would have had to learn it.print_items, and here the config is also a Rust closure.Generated by Claude Code