#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum Scope {
Singleton,
Transient,
}
impl Scope {
pub fn is_singleton(&self) -> bool {
matches!(self, Scope::Singleton)
}
pub fn is_transient(&self) -> bool {
matches!(self, Scope::Transient)
}
}
#[cfg(test)]
mod tests {
#[test]
fn test_scope_singleton_check() {
assert!(crate::container::scope::Scope::Singleton.is_singleton());
assert!(!crate::container::scope::Scope::Singleton.is_transient());
}
#[test]
fn test_scope_transient_check() {
assert!(crate::container::scope::Scope::Transient.is_transient());
assert!(!crate::container::scope::Scope::Transient.is_singleton());
}
#[test]
fn test_scope_equality() {
assert_eq!(
crate::container::scope::Scope::Singleton,
crate::container::scope::Scope::Singleton
);
assert_eq!(
crate::container::scope::Scope::Transient,
crate::container::scope::Scope::Transient
);
assert_ne!(
crate::container::scope::Scope::Singleton,
crate::container::scope::Scope::Transient
);
}
}