1#![cfg_attr(not(feature="std"), no_std)]
4
5#[cfg(feature="std")]
6extern crate core;
7
8use core::fmt::Display;
9
10#[derive(Debug,Default)]
11pub struct InvalidEnumValue(());
12
13const DESCRIPTION : &str = "Attempted to convert invalid value to enum";
14
15impl InvalidEnumValue {
16 pub fn new() -> Self {
17 InvalidEnumValue(())
18 }
19}
20
21impl Display for InvalidEnumValue {
22 fn fmt(&self, fmt: &mut core::fmt::Formatter) -> core::fmt::Result {
23 DESCRIPTION.fmt(fmt)
24 }
25}
26
27#[cfg(feature="std")]
28impl std::error::Error for InvalidEnumValue {
29 fn description(&self) -> &str {
30 DESCRIPTION
31 }
32}
33
34#[cfg(all(test, feature="std"))]
35mod tests {
36 use super::*;
37 use std::error::Error;
38
39 #[test]
40 fn test_description() {
41 assert_eq!(InvalidEnumValue::new().description(), DESCRIPTION);
42 }
43}