use std::cmp::Ordering; #[derive(Clone, Copy, Debug, PartialEq, Eq)] pub enum LogLevel { /// Verbose record of decisions and operations. Info, /// Report recoverable issues. Warn, /// Report recoverable process errors. Error, /// Report unrecoverable application errors and quit. Fatal, } impl PartialOrd for LogLevel { fn partial_cmp(&self, other: &LogLevel) -> Option { Some(self.cmp(other)) } } impl Ord for LogLevel { fn cmp(&self, other: &LogLevel) -> Ordering { use LogLevel::*; match (self, other) { (Info , Info ) => Ordering::Equal, (Info , Warn ) => Ordering::Less, (Info , Error) => Ordering::Less, (Info , Fatal) => Ordering::Less, (Warn , Info ) => Ordering::Greater, (Warn , Warn ) => Ordering::Equal, (Warn , Error) => Ordering::Less, (Warn , Fatal) => Ordering::Less, (Error , Info ) => Ordering::Greater, (Error , Warn ) => Ordering::Greater, (Error , Error) => Ordering::Equal, (Error , Fatal) => Ordering::Less, (Fatal , Info ) => Ordering::Greater, (Fatal , Warn ) => Ordering::Greater, (Fatal , Error) => Ordering::Greater, (Fatal , Fatal) => Ordering::Equal, } } }