AK: Don't inherit Formatter<ErrorOr<T>> for Formatter<IPv4Address>

This commit is contained in:
MacDue 2023-01-13 02:21:33 +00:00 committed by Linus Groh
parent 2150e1b3a5
commit d5152c49a1

View file

@ -158,18 +158,18 @@ struct Traits<IPv4Address> : public GenericTraits<IPv4Address> {
#ifdef KERNEL #ifdef KERNEL
template<> template<>
struct Formatter<IPv4Address> : Formatter<ErrorOr<NonnullOwnPtr<Kernel::KString>>> { struct Formatter<IPv4Address> : Formatter<StringView> {
ErrorOr<void> format(FormatBuilder& builder, IPv4Address value) ErrorOr<void> format(FormatBuilder& builder, IPv4Address value)
{ {
return Formatter<ErrorOr<NonnullOwnPtr<Kernel::KString>>>::format(builder, TRY(value.to_string())); return Formatter<StringView>::format(builder, TRY(value.to_string())->view());
} }
}; };
#else #else
template<> template<>
struct Formatter<IPv4Address> : Formatter<DeprecatedString> { struct Formatter<IPv4Address> : Formatter<StringView> {
ErrorOr<void> format(FormatBuilder& builder, IPv4Address value) ErrorOr<void> format(FormatBuilder& builder, IPv4Address value)
{ {
return Formatter<DeprecatedString>::format(builder, value.to_deprecated_string()); return Formatter<StringView>::format(builder, value.to_deprecated_string());
} }
}; };
#endif #endif