#[derive(Debug, Clone, PartialEq, Eq)]
pub enum Autoincrement<T>
where
T: std::fmt::Debug + Clone + PartialEq + Eq,
{
Auto,
Value(T),
}
impl<T> Autoincrement<T>
where
T: std::fmt::Debug + Clone + PartialEq + Eq,
{
pub fn into_option(self) -> Option<T> {
match self {
Autoincrement::Auto => None,
Autoincrement::Value(v) => Some(v),
}
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_autoincrement_into_option() {
let auto = Autoincrement::<i32>::Auto;
let value = Autoincrement::Value(42);
assert_eq!(auto.into_option(), None);
assert_eq!(value.into_option(), Some(42));
}
}