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

FormatWith should implement fmt::Debug #929

Closed
m-mueller678 opened this issue May 3, 2024 · 1 comment · Fixed by #931
Closed

FormatWith should implement fmt::Debug #929

m-mueller678 opened this issue May 3, 2024 · 1 comment · Fixed by #931

Comments

@m-mueller678
Copy link

The value returned by format_with should implement std::fmt::Debug. Similar to the value returned by std::format_args, the Debug representation should be the same as the Display one. This allows using it in places like std::fmt::DebugStruct.

@Philippe-Cholet
Copy link
Member

Similarly to https://doc.rust-lang.org/src/core/fmt/mod.rs.html#451 we could indeed delegate to Display:

impl<'a, I, F> fmt::Debug for FormatWith<'a, I, F>
where
    I: Iterator,
    F: FnMut(I::Item, &mut dyn FnMut(&dyn fmt::Display) -> fmt::Result) -> fmt::Result,
{
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
        fmt::Display::fmt(self, f)
    }
}

I don't see an issue with this, but I'm not familiar with those Format/FormatWith.
@phimuemue @jswrenn Any objection?

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 a pull request may close this issue.

2 participants