diff options
author | Linus Groh <mail@linusgroh.de> | 2021-12-28 17:42:14 +0100 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2022-01-03 21:50:50 +0100 |
commit | 85f0fc2b83a83c842144018a8643ac471cf0c33f (patch) | |
tree | 5e86284cd2d10aa380c08c495a80edd8393c4d87 /Userland/Applications | |
parent | b39aede8fe19e7ef17ddc7f52c9ed1decef30e78 (diff) | |
download | serenity-85f0fc2b83a83c842144018a8643ac471cf0c33f.zip |
LibJS: Return Optional<T> from Completion::{value,target}(), not T
In the end this is a nicer API than having separate has_{value,target}()
and having to check those first, and then making another Optional from
the unwrapped value:
completion.has_value() ? completion.value() : Optional<Value> {}
// ^^^^^^^^^^^^^^^^^^
// Implicit creation of non-empty Optional<Value>
This way we need to unwrap the optional ourselves, but can easily pass
it to something else as well.
This is in anticipation of the AST using completions :^)
Diffstat (limited to 'Userland/Applications')
-rw-r--r-- | Userland/Applications/Spreadsheet/SpreadsheetModel.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/Userland/Applications/Spreadsheet/SpreadsheetModel.cpp b/Userland/Applications/Spreadsheet/SpreadsheetModel.cpp index 86e78bf91f..8be1f77dc7 100644 --- a/Userland/Applications/Spreadsheet/SpreadsheetModel.cpp +++ b/Userland/Applications/Spreadsheet/SpreadsheetModel.cpp @@ -51,7 +51,7 @@ GUI::Variant SheetModel::data(const GUI::ModelIndex& index, GUI::ModelRole role) auto error_message = value.to_string(cell->sheet().global_object()); if (error_message.is_throw_completion()) - return to_string_as_exception(error_message.release_error().value()); + return to_string_as_exception(*error_message.release_error().value()); builder.append(error_message.release_value()); return builder.to_string(); @@ -64,7 +64,7 @@ GUI::Variant SheetModel::data(const GUI::ModelIndex& index, GUI::ModelRole role) auto display = cell->typed_display(); if (display.is_error()) - return to_string_as_exception(display.release_error().value()); + return to_string_as_exception(*display.release_error().value()); return display.release_value(); } |