1use core::error::Error;
4use core::fmt::{Debug, Display, Formatter};
5
6#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
11pub struct UnknownVariant<T>(pub T);
12
13impl<T: Copy> UnknownVariant<T> {
14 pub const fn new(value: T) -> Self {
15 Self(value)
16 }
17
18 pub const fn value(&self) -> T {
20 self.0
21 }
22}
23
24impl<T: Copy + Display> Display for UnknownVariant<T> {
25 fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), core::fmt::Error> {
26 write!(f, "Unknown enum variant: {}", self.0)
27 }
28}
29
30impl<T: Copy + Debug + Display> Error for UnknownVariant<T> {}