use std::fmt;
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
#[non_exhaustive]
pub enum Model {
Needle,
Whistle,
}
impl Model {
#[inline]
#[must_use]
pub const fn as_str(self) -> &'static str {
match self {
Model::Needle => "Needle",
Model::Whistle => "Whistle",
}
}
#[inline]
#[must_use]
pub const fn archive(self) -> &'static str {
match self {
Model::Needle => "needle3.cact",
Model::Whistle => "whistle.cact",
}
}
}
impl fmt::Display for Model {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.write_str(self.as_str())
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn display_is_the_name() {
for model in [Model::Needle, Model::Whistle] {
assert_eq!(model.to_string(), model.as_str());
}
}
#[test]
fn archives_are_distinct() {
assert_ne!(Model::Needle.archive(), Model::Whistle.archive());
}
}