-
Notifications
You must be signed in to change notification settings - Fork 567
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
write! for RichTextBuilder #1596
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting. I trust you've found this useful for something and it's not very intrusive, so I'm happy to merge. A few little questions inline, but nothing blocking.
/// Glue for usage of the write! macro. | ||
/// | ||
/// This method should generally not be invoked manually, but rather through the write! macro itself. | ||
pub fn write_fmt(&mut self, fmt: std::fmt::Arguments<'_>) -> AttributesAdder { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe add #[doc(hidden)]
on this, since it's really an implementation detail and doesn't need to show up in public docs?
Hmm, should we be implementing the Write
trait directly? Is this depending on an implementation detail of the macro, where it calls write_fmt
with no qualifiers, instead of doing like Write::write_fmt(writer, args)
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't implement Write
because it returns a Result, I wanted it to feel more like format!
.
Is this depending on an implementation detail of the macro?
the docs say it just needs something with write_fmt
method.
The writer may be any value with a write_fmt method; generally this comes from an implementation of either the fmt::Write or the io::Write trait.
I found myself doing a lot of |
It's possible this also saves us an intermediate allocation, although I'm not sure about this part. |
* write! for RichTextBuilder * panic on formatting error * Fix doc test * Make write_fmt doc hidden Co-authored-by: Colin Rofls <[email protected]>
No description provided.