diff --git a/luna/include/luna/Result.h b/luna/include/luna/Result.h index 9b1114d2..b5f128e4 100644 --- a/luna/include/luna/Result.h +++ b/luna/include/luna/Result.h @@ -127,6 +127,13 @@ template class Result return m_value.unchecked_release_value({}); } + static Result from_option(Option&& option, int error) + { + if (option.has_value()) { return option.unchecked_release_value({}); } + else + return Error { error }; + } + private: Option m_value; int m_error;