summaryrefslogtreecommitdiff
path: root/AK
diff options
context:
space:
mode:
Diffstat (limited to 'AK')
-rw-r--r--AK/Format.h27
1 files changed, 23 insertions, 4 deletions
diff --git a/AK/Format.h b/AK/Format.h
index b493b3c557..48682c2dbe 100644
--- a/AK/Format.h
+++ b/AK/Format.h
@@ -329,15 +329,16 @@ struct Formatter<StringView> : StandardFormatter {
ErrorOr<void> format(FormatBuilder&, StringView);
};
-template<typename T, size_t inline_capacity>
-requires(HasFormatter<T>) struct Formatter<Vector<T, inline_capacity>> : StandardFormatter {
-
+template<typename T>
+requires(HasFormatter<T>)
+struct Formatter<Span<T const>> : StandardFormatter {
Formatter() = default;
explicit Formatter(StandardFormatter formatter)
: StandardFormatter(move(formatter))
{
}
- ErrorOr<void> format(FormatBuilder& builder, Vector<T> value)
+
+ ErrorOr<void> format(FormatBuilder& builder, Span<T const> value)
{
if (m_mode == Mode::Pointer) {
Formatter<FlatPtr> formatter { *this };
@@ -375,6 +376,24 @@ requires(HasFormatter<T>) struct Formatter<Vector<T, inline_capacity>> : Standar
}
};
+template<typename T>
+requires(HasFormatter<T>)
+struct Formatter<Span<T>> : Formatter<Span<T const>> {
+ ErrorOr<void> format(FormatBuilder& builder, Span<T> value)
+ {
+ return Formatter<Span<T const>>::format(builder, value);
+ }
+};
+
+template<typename T, size_t inline_capacity>
+requires(HasFormatter<T>)
+struct Formatter<Vector<T, inline_capacity>> : Formatter<Span<T const>> {
+ ErrorOr<void> format(FormatBuilder& builder, Vector<T, inline_capacity> const& value)
+ {
+ return Formatter<Span<T const>>::format(builder, value.span());
+ }
+};
+
template<>
struct Formatter<ReadonlyBytes> : Formatter<StringView> {
ErrorOr<void> format(FormatBuilder& builder, ReadonlyBytes value)