Skip to content
Derive for the Display trait
Branch: master
Clone or download
Latest commit 5d6bac2 Feb 1, 2018
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src Derive for the Display trait. Feb 1, 2018
tests Derive for the Display trait. Feb 1, 2018
.gitignore Derive for the Display trait. Feb 1, 2018
Cargo.toml Derive for the Display trait. Feb 1, 2018
README.md

README.md

Derive Display

A derive for the Display trait.

#[macro_use] extern crate display_derive;

#[derive(Display)]
#[display(fmt = "Error code: {}", code)]
struct RecordError {
    code: u32,
}

#[derive(Display)]
enum EnumError {
    #[display(fmt = "Error code: {}", code)]
    StructVariant {
        code: i32,
    },
    #[display(fmt = "Error: {}", _0)]
    TupleVariant(&'static str),
    #[display(fmt = "An error has occurred.")]
    UnitVariant,
}
You can’t perform that action at this time.