failure icon indicating copy to clipboard operation
failure copied to clipboard

Allow arbitrary expressions in #[fail(display = "...")]

Open remexre opened this issue 6 years ago • 1 comments

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?

remexre avatar Mar 11 '18 13:03 remexre

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

frol avatar Mar 12 '18 08:03 frol