#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum InsertedIdentity {
Unknown,
Vacant,
Unused,
}
impl InsertedIdentity {
pub fn is_vacant(self) -> bool {
self != Self::Unknown
}
pub fn is_unused(self) -> bool {
self == Self::Unused
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn each_level_of_knowledge_includes_the_ones_below_it() {
assert!(!InsertedIdentity::Unknown.is_vacant());
assert!(!InsertedIdentity::Unknown.is_unused());
assert!(InsertedIdentity::Vacant.is_vacant());
assert!(!InsertedIdentity::Vacant.is_unused());
assert!(InsertedIdentity::Unused.is_vacant());
assert!(InsertedIdentity::Unused.is_unused());
}
}