From 3e09cabb6abe2c05e0b792c79d88cc02a2c62d52 Mon Sep 17 00:00:00 2001 From: John Spray Date: Mon, 4 Sep 2023 14:58:03 +0100 Subject: [PATCH] libs: implement Generation Into --- 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 163c8c0467..8f70eb2ed2 100644 --- a/libs/utils/src/generation.rs +++ b/libs/utils/src/generation.rs @@ -89,6 +89,14 @@ impl Generation { Self::Broken => panic!("Attempted to use a broken generation"), } } + + pub fn into(self) -> Option { + if let Self::Valid(v) = self { + Some(v) + } else { + None + } + } } impl Serialize for Generation {