From a3e7c468cd0928a2ac7905d390cc4ab7fb93ebc7 Mon Sep 17 00:00:00 2001 From: Irevoire Date: Wed, 13 Oct 2021 13:05:07 +0200 Subject: [PATCH] add helper methods on the settings --- milli/src/update/settings.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/milli/src/update/settings.rs b/milli/src/update/settings.rs index 41c156676..dee63c726 100644 --- a/milli/src/update/settings.rs +++ b/milli/src/update/settings.rs @@ -28,6 +28,21 @@ impl Default for Setting { } impl Setting { + pub fn set(self) -> Option { + match self { + Self::Set(value) => Some(value), + _ => None, + } + } + + pub const fn as_ref(&self) -> Setting<&T> { + match *self { + Self::Set(ref value) => Setting::Set(value), + Self::Reset => Setting::Reset, + Self::NotSet => Setting::NotSet, + } + } + pub const fn is_not_set(&self) -> bool { matches!(self, Self::NotSet) }