diff --git a/source/coral.cpp b/source/coral.cpp index ace6e29..fba2a8a 100755 --- a/source/coral.cpp +++ b/source/coral.cpp @@ -446,7 +446,7 @@ export namespace coral { template using rebound = expected; /** - * Constructs from `value`, creating an [expected] that contains the expected type. + * Constructs from `value`, creating an [expected] with the expected type. */ expected(expects const & value) { (*reinterpret_cast(this->buffer)) = value; @@ -454,12 +454,19 @@ export namespace coral { } /** - * Constructs from `error`, creating an [expected] that does not contain the expected type. + * Constructs from `error`, creating an [expected] with an error. */ expected(errors const & error) { (*reinterpret_cast(this->buffer)) = error; } + /** + * Invokes the `apply` procedure if the expected is not ok, otherwise having no side-effects. + */ + void and_then(closure const & apply) { + if (this->is_ok()) apply(**this); + } + /** * Returns the contained error as an [optional]. */