Result: Construct a Result from an Option using from_option()
This commit is contained in:
parent
79a5b98d65
commit
0e1e15e85a
@ -127,6 +127,13 @@ template <typename T> class Result
|
||||
return m_value.unchecked_release_value({});
|
||||
}
|
||||
|
||||
static Result<T> from_option(Option<T>&& option, int error)
|
||||
{
|
||||
if (option.has_value()) { return option.unchecked_release_value({}); }
|
||||
else
|
||||
return Error { error };
|
||||
}
|
||||
|
||||
private:
|
||||
Option<T> m_value;
|
||||
int m_error;
|
||||
|
Loading…
Reference in New Issue
Block a user