mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 23:47:45 +00:00
AK: Use new Formatter for each element in Formatter<Vector<T>>
The state of the formatter for the previous element should be thrown away for each iteration. This showed up when trying to format a Vector<String>, since Formatter<StringView> was unhappy about some state that gets set when it's called. Add a test for Formatter<Vector>.
This commit is contained in:
parent
4842c8c902
commit
64aac345d3
2 changed files with 20 additions and 1 deletions
|
@ -354,8 +354,10 @@ requires(HasFormatter<T>) struct Formatter<Vector<T>> : StandardFormatter {
|
|||
builder.put_literal("[ "sv);
|
||||
bool first = true;
|
||||
for (auto& content : value) {
|
||||
if (!first)
|
||||
if (!first) {
|
||||
builder.put_literal(", "sv);
|
||||
content_fmt = Formatter<T> {};
|
||||
}
|
||||
first = false;
|
||||
content_fmt.format(builder, content);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue