use core::fmt;
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
#[non_exhaustive]
pub enum SearchType {
Score,
ScoreEnd,
}
impl SearchType {
#[must_use]
pub const fn tracks_end(self) -> bool {
matches!(self, SearchType::ScoreEnd)
}
}
impl fmt::Display for SearchType {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
SearchType::Score => f.write_str("Score"),
SearchType::ScoreEnd => f.write_str("ScoreEnd"),
}
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn only_score_end_tracks_end() {
assert!(!SearchType::Score.tracks_end());
assert!(SearchType::ScoreEnd.tracks_end());
}
#[test]
fn display_round_trips_names() {
assert_eq!(SearchType::Score.to_string(), "Score");
assert_eq!(SearchType::ScoreEnd.to_string(), "ScoreEnd");
}
}