#![allow(clippy::upper_case_acronyms)]
use std::cmp::Ordering;
use num_enum::{IntoPrimitive, TryFromPrimitive};
use strum::IntoEnumIterator;
use strum_macros::{AsRefStr, Display, EnumString, IntoStaticStr};
#[derive(
Debug,
Copy,
Clone,
Eq,
PartialEq,
Hash,
EnumString,
Display,
AsRefStr,
IntoStaticStr,
IntoPrimitive,
TryFromPrimitive,
serde::Serialize,
crate::de::Deserialize,
)]
#[repr(u8)]
pub enum Division {
I = 1,
II = 2,
III = 3,
IV = 4,
#[deprecated(note = "Removed for 2019.")]
V = 5,
}
impl IntoEnumIterator for Division {
type Iterator = std::iter::Copied<std::slice::Iter<'static, Self>>;
fn iter() -> Self::Iterator {
[Self::I, Self::II, Self::III, Self::IV].iter().copied()
}
}
impl Ord for Division {
fn cmp(&self, other: &Self) -> Ordering {
u8::from(*self).cmp(&u8::from(*other)).reverse()
}
}
impl PartialOrd for Division {
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
Some(self.cmp(other))
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn sort() {
assert!(Division::IV < Division::I);
}
}