I have an Displayed enum with a custom format on each variant, like this:
#[derive(Display)]
enum SomeEnum {
#[display("valuea:{0}")]
ValueA(String),
#[display("valueb:{0}")]
ValueB(String),
#[display("valuec:{0}")]
ValueC(String),
}
It'd be nice to make this more readable by using the lowercase term in the format, such as #[display("{lowercase}:{0}")] or #[display("{}:{0}", lowercase)]. A drawback of the former is ambiguity if the variant contains a lowercase field (positional format args don't appear to be accepted currently), so the latter is likely the preferred form.
Even better would be this:
#[derive(Display)]
#[display("{}:{0}", lowercase)]
enum SomeEnum {
ValueA(String),
ValueB(String),
ValueC(String),
#[display(lowercase)]
Other // breaks above convention
}
I have an
Displayed enum with a custom format on each variant, like this:It'd be nice to make this more readable by using the
lowercaseterm in the format, such as#[display("{lowercase}:{0}")]or#[display("{}:{0}", lowercase)]. A drawback of the former is ambiguity if the variant contains alowercasefield (positional format args don't appear to be accepted currently), so the latter is likely the preferred form.Even better would be this: