Skip to content

Conversation

epage
Copy link
Contributor

@epage epage commented Oct 3, 2025

While std::io::Write only has a few required methods,
while implementing anstream I found its better to implement
as many as possible when dealing with stdout or stderr
so that the implicitly acquired lock is aquired once for the call,
rather than multiple times as the inherent methods break down a single higher
level calls into multiple lower level calls.

This is likely not a problem right now but the different layers of APIs, especially in interacting with tracing, could hit problems with this in the future.

epage added 2 commits October 3, 2025 14:58
While `std::io::Write` only has a few required methods,
while implementing `anstream` I found its better to implement
as many as possible when dealing with `stdout` or `stderr`
so that the implicitly acquired lock is aquired once for the call,
rather than multiple times as the inherent methods break down a single higher
level calls into multiple lower level calls.
Copy link
Contributor

@djc djc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense, thanks!

}
}

impl TerminalInner {
Copy link
Contributor

@djc djc Oct 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: ordering in this module is a bit of a mess, but please keep impls directly below their respective type's definitions.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was trying to be consistent with the file which seemed to be types before impls (mostly). But fine with changing this.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I think that would be nice. I'll clean up the other items after this is merged.

(Note that CI is failing on a formatting issue.)

Copy link
Member

@rami3l rami3l left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Many thanks! Just address whatever suggestions @djc may have and I think this PR is good to go 🙏

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.

3 participants