You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It'd be really nice to be able to derive Display and use an affix (prefix and/or suffix) that comes before each inner implementation of Display. This is particularly handy for errors; an example I'm hoping to work with might look like:
#[derive(Debug,Display)]// Expects a single Display item corresponding to where an inner // variant's Display will be written (`{}`), otherwise errors#[display(affix = "unable to read from /proc/stat: {}")]pub(crate)enumSnapshotReadError{Io(IoError),#[display(fmt = "expected CPU stat line for {}, got {:#?}", expected_cpu, line)]UnableToParseLine{expected_cpu:CpuComponent,line:String,}}#[derive(Debug,Display)]pub(crate)enumCpuComponent{#[display(fmt = "entire CPU")]EntireCpu,#[display(fmt = "CPU core {}", _0)]Core(usize),}
What do you think?
Please note: I specifically chose a terrible but concise word for this which I fully expect to be bikeshedded. Alternatives might include:
outer_fmt (I like this one the best.)
prefix (but it's not just a prefix!)
surround
The text was updated successfully, but these errors were encountered:
The reason I didn't simply file a PR initially is because I hacked the support together to demonstrate via test/ what this would look like, and don't particularly like the commit as-is. I'll just mark the PR [WIP] and be patient when it comes time to clean things up. :)
It'd be really nice to be able to derive
Display
and use an affix (prefix and/or suffix) that comes before each inner implementation ofDisplay
. This is particularly handy for errors; an example I'm hoping to work with might look like:What do you think?
Please note: I specifically chose a terrible but concise word for this which I fully expect to be bikeshedded. Alternatives might include:
outer_fmt
(I like this one the best.)prefix
(but it's not just a prefix!)surround
The text was updated successfully, but these errors were encountered: