#[non_exhaustive] 属性

版本新特性 / Rust 1.40

// *** before: ***
// adding a field or a variant broke the build for every user of the crate,
// so a hidden placeholder variant was put into the enum
pub enum Error {
    NotFound,
    Timeout,
    #[doc(hidden)]
    __Nonexhaustive,
}

// *** in version 1.40: ***
#[non_exhaustive]
pub enum Error {
    NotFound,
    Timeout,
}

// outside the crate, a match on such an enum must have a _ arm