Skip to content

Commit

Permalink
Fix compile error in FixedAppender.
Browse files Browse the repository at this point in the history
  • Loading branch information
s-ludwig committed Feb 15, 2024
1 parent 6c67e7d commit dc885ee
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion source/vibe/container/internal/appender.d
Original file line number Diff line number Diff line change
Expand Up @@ -228,10 +228,12 @@ struct FixedAppender(ArrayType : E[], size_t NELEM, E) {
static if( is(ElemType == char) ){
void put(dchar el)
{
import std.utf : encode;

if( el < 128 ) put(cast(char)el);
else {
char[4] buf;
auto len = std.utf.encode(buf, el);
auto len = encode(buf, el);
put(cast(ArrayType)buf[0 .. len]);
}
}
Expand Down Expand Up @@ -261,3 +263,11 @@ struct FixedAppender(ArrayType : E[], size_t NELEM, E) {
void reset() { m_fill = 0; }
}
}

unittest {
FixedAppender!(string, 16) app;
app.put("foo");
app.put('b');
app.put("ar");
assert(app.data == "foobar");
}

0 comments on commit dc885ee

Please sign in to comment.