Skip to content

Conversation

@joboet
Copy link
Member

@joboet joboet commented Aug 29, 2025

This avoids having to create a new Arguments just for printing a string.

@rustbot
Copy link
Collaborator

rustbot commented Aug 29, 2025

r? @Mark-Simulacrum

rustbot has assigned @Mark-Simulacrum.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Aug 29, 2025
@hanna-kruppe
Copy link
Contributor

hanna-kruppe commented Aug 29, 2025

If the motivation here is reducing code size, note that field_with consist of quite a lot of code (also for DebugStruct) that'll get monomorphized for each distinct closure type.

A possible alternative is d.field($(name,)? &fmt::from_fn(|f| f.write_str(...))). Although this will have a separate Debug vtable for each call site, so it's not obvious to me that it's better than Arguments construction for code size. The most economic but most annoying option would probably be to have a single monomorphic type that holds a string and implements Debug as f.write_str(self.the_string).

@joboet
Copy link
Member Author

joboet commented Aug 29, 2025

Right, fair enough!

@joboet joboet closed this Aug 29, 2025
@rustbot rustbot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Aug 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

T-libs Relevant to the library team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants