From 34007e12a10ebeb01aa89533b011c9be572cbf76 Mon Sep 17 00:00:00 2001 From: John Spray Date: Mon, 11 Sep 2023 17:59:02 +0100 Subject: [PATCH] libs: add Generation::next --- libs/utils/src/generation.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/libs/utils/src/generation.rs b/libs/utils/src/generation.rs index 8f70eb2ed2..88d50905c6 100644 --- a/libs/utils/src/generation.rs +++ b/libs/utils/src/generation.rs @@ -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 { if let Self::Valid(v) = self { Some(v)