mirror of
https://github.com/fergalmoran/ladybird.git
synced 2025-12-22 09:19:03 +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:
committed by
Andreas Kling
parent
8ff6239d4f
commit
41cf52a623
@@ -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);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user