failure
failure copied to clipboard
Allow arbitrary expressions in #[fail(display = "...")]
This'd make the ergonomics around (at a minimum) PathBuf
a lot nicer; right now:
#[derive(Debug, Fail)]
pub enum Error {
/// An error opening a source file.
#[fail(display = "Couldn't open `{:?}': {}", _0, _1)]
CouldntOpenSource(PathBuf, IoError),
// ...
}
doesn't work, since PathBuf: !Display
.
#[fail(display = "Couldn't open `{:?}': {}", _0.display(), _1)]
doesn't work, since attributes can't contain arbitrary expressions.
#[fail(display = "Couldn't open `{:?}': {}", "_0.display()", _1)]
doesn't work, but could?
Given #[fail(display)]
functionality has been moved into a separate crate display_derive
in failure 1.x, I think this issue should be opened there: https://github.com/withoutboats/display_derive