Yi Kong | ce81bb6 | 2020-08-31 01:21:33 +0800 | [diff] [blame] | 1 | use core::fmt::{self, Display}; |
2 | |||||
3 | #[derive(Copy, Clone, Debug)] | ||||
4 | pub enum Error { | ||||
5 | InputTooShort, | ||||
6 | InputTooLong, | ||||
7 | MalformedInput, | ||||
8 | } | ||||
9 | |||||
10 | impl Display for Error { | ||||
11 | fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { | ||||
12 | let msg = match self { | ||||
13 | Error::InputTooShort => "input too short", | ||||
14 | Error::InputTooLong => "input too long", | ||||
15 | Error::MalformedInput => "malformed input", | ||||
16 | }; | ||||
17 | formatter.write_str(msg) | ||||
18 | } | ||||
19 | } |