mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-25 00:50:22 +00:00
AK: Make the Optional formatter always available and tweak its format
There's no real reason to make this a debug-only formatter, on top of that, jakt has a optional formatter that prints None/foo instead of OptionalNone/Optional(foo), which is more concise anyway, so switch to that.
This commit is contained in:
parent
8ff6239d4f
commit
41cf52a623
Notes:
sideshowbarker
2024-07-17 07:06:47 +09:00
Author: https://github.com/alimpfard Commit: https://github.com/SerenityOS/serenity/commit/41cf52a623 Pull-request: https://github.com/SerenityOS/serenity/pull/18551
1 changed files with 2 additions and 4 deletions
|
@ -717,13 +717,11 @@ struct Formatter<ErrorOr<T, ErrorType>> : Formatter<FormatString> {
|
|||
|
||||
template<typename T>
|
||||
struct Formatter<Optional<T>> : Formatter<FormatString> {
|
||||
static constexpr bool is_debug_only() { return true; }
|
||||
|
||||
ErrorOr<void> format(FormatBuilder& builder, Optional<T> const& optional)
|
||||
{
|
||||
if (optional.has_value())
|
||||
return Formatter<FormatString>::format(builder, "Optional({})"sv, *optional);
|
||||
return builder.put_literal("OptionalNone"sv);
|
||||
return Formatter<FormatString>::format(builder, "{}"sv, *optional);
|
||||
return builder.put_literal("None"sv);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue