mirror of
https://github.com/SerenityOS/serenity
synced 2024-10-02 22:24:26 +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
|
@ -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