oxedyne/fe2o3/fe2o3_core/src/bool.rs
683 bytes, 1 run
created by r1870400018:62, which is this file's identity for as long as the history lasts, whatever it is later renamed to
download · who wrote it · its history
| 1 | use std::fmt; |
| 2 | |
| 3 | #[derive(Clone, Debug)] |
| 4 | pub enum BoolFormatter { |
| 5 | TrueFalse(bool), |
| 6 | OnOff(bool), |
| 7 | YesNo(bool), |
| 8 | } |
| 9 | |
| 10 | impl fmt::Display for BoolFormatter { |
| 11 | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { |
| 12 | match self { |
| 13 | Self::TrueFalse(b) => if *b { |
| 14 | write!(f, "true") |
| 15 | } else { |
| 16 | write!(f, "false") |
| 17 | }, |
| 18 | Self::OnOff(b) => if *b { |
| 19 | write!(f, "on") |
| 20 | } else { |
| 21 | write!(f, "off") |
| 22 | }, |
| 23 | Self::YesNo(b) => if *b { |
| 24 | write!(f, "yes") |
| 25 | } else { |
| 26 | write!(f, "no") |
| 27 | }, |
| 28 | } |
| 29 | } |
| 30 | } |