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`