Subset enums
Rust Internals [Unofficial]
March 3, 2026
Based on the syntax supported by pattern types (when they emerge) would my example be re-worked to be like:
#[derive(Debug, Error)]
pub enum MyError {
#[error("not found")]
NotFound,
#[error("invalid state")]
InvalidState,
#[error("permission denied")]
PermissionDenied,
}
pub enum MyErrorSubset {
NotFound is MyError::NotFound,
PermissionDenied is MyError::PermissionDenied,
}
This seems like making the parent a repr type and using as.
Discussion in the ATmosphere