libs: add Generation::next

This commit is contained in:
John Spray
2023-09-11 17:59:02 +01:00
parent 278eb70522
commit 34007e12a1

View File

@@ -90,6 +90,14 @@ impl Generation {
}
}
pub fn next(&self) -> Generation {
match self {
Self::Valid(n) => Self::Valid(*n + 1),
Self::None => Self::Valid(1),
Self::Broken => panic!("Attempted to use a broken generation"),
}
}
pub fn into(self) -> Option<u32> {
if let Self::Valid(v) = self {
Some(v)