From 8ec7ea3167863357be55d851b0e27cf5db66ee46 Mon Sep 17 00:00:00 2001 From: Sean Register Date: Fri, 21 Nov 2025 10:17:11 +0000 Subject: [PATCH] `into_option_or` --- reflectapi/src/option.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/reflectapi/src/option.rs b/reflectapi/src/option.rs index dbcc2506..19acf2eb 100644 --- a/reflectapi/src/option.rs +++ b/reflectapi/src/option.rs @@ -90,6 +90,16 @@ impl Option { } } + /// Converts the `Option` into a standard `Option`. + /// Returning `default` if the value is `Undefined`. + pub fn into_option_or(self, default: T) -> std::option::Option { + match self { + Option::Undefined => Some(default), + Option::None => None, + Option::Some(value) => Some(value), + } + } + /// Converts a reference to a `Option` into an `Option<&T>`. /// /// Note: This is a lossy conversion, as both `Undefined` and `None`