rushmorem / derive-error

Derive macro for Error using macros 1.1
Apache License 2.0
32 stars 4 forks source link

Format description from argument #5

Open Tarmil opened 5 years ago

Tarmil commented 5 years ago

I've recently needed something like the following:

#[derive(Debug, Error)]
enum Error {
    /// Unknown target: {}
    #[error(no_from, non_std)]
    UnknownTarget(String),
}

so that UnknownTarget("foo".to_owned()) would have "Unknown target: foo" as its description.

Currently the above actually fails to compile with error: 1 positional argument in format string, but no arguments were given, so this would not be a breaking change.