-
-
Notifications
You must be signed in to change notification settings - Fork 163
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
Consider exposing formatter in display attribute #201
Comments
For a concrete motivation for this request, I have the following definition:
later, I use it in cases where I want to see the whole thing that lacks the inner thing:
and also in places where there simply isn't a thing at all to see:
|
Personally, I'd prefer something like #[derive(Error, Debug)]
pub enum DummyError {
#[error(with = display_what_happened)]
WhatHappened(io::Error, PathBuf),
}
fn display_what_happened(err: &io::Error, path: &PathBuf, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
todo!()
} Personally I prefer this version, as while all the others are nice. They basically instantly break auto-formatting. |
For this sort of code today [#175 (comment)]:
one might instead write something like this, without any
String
allocation:or possibly this:
Unclear whether either of these is that much better than:
or, using an adapter around
Fn(&mut fmt::Formatter) -> fmt::Result
to trim the boilerplate:The text was updated successfully, but these errors were encountered: