Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce global print functions #21

Merged
merged 10 commits into from
Jan 21, 2025
Merged

Introduce global print functions #21

merged 10 commits into from
Jan 21, 2025

Conversation

schneems
Copy link
Collaborator

  • Introduces bullet_stream::global::print functions for printing without needing to jump through strict type checked stateful hoops. It's less safe, but faster to get up and running.
  • Introduces Print::global() which supports resuming printing after an error.

@schneems schneems force-pushed the schneems/global-gym branch from 11f39c8 to 456fbfe Compare January 15, 2025 22:22
@schneems schneems marked this pull request as ready for review January 15, 2025 23:17

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
This moves the bulk of write formatting out of the Print struct state machine. This opens up the ability to re-use it with a global writer and retain consistent formatting.
Today if an error causes a `Print` struct to be dropped, there's no way to know later if the next line needs to be empty or not. This PR introduces a global writer that tracks the number of newlines previously written to the output. Calling `Print::global` tells the writer to use that prior information when resuming.
Details in the module docs and style guide
@schneems schneems force-pushed the schneems/global-gym branch from a960c4c to c7d8b6f Compare January 21, 2025 19:37
@schneems schneems merged commit ad7825c into main Jan 21, 2025
5 checks passed
@schneems schneems deleted the schneems/global-gym branch January 21, 2025 19:46
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.

None yet

1 participant