Skip to content

Commit 59c6c3d

Browse files
committed
Add opOpAssign alias for put
1 parent 7a57bc8 commit 59c6c3d

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

source/mir/appender.d

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,9 @@ struct ScopedBuffer(T, size_t bytes = 4096)
245245
}
246246
}
247247

248+
///
249+
alias opOpAssign(string op : "~") = put;
250+
248251
///
249252
void reset() scope nothrow
250253
{
@@ -326,6 +329,18 @@ version (mir_test) unittest
326329
assert(buf.data == "cs");
327330
}
328331

332+
@safe pure nothrow @nogc
333+
version (mir_test) unittest
334+
{
335+
auto buf = scopedBuffer!(char, 3);
336+
buf ~= 'c';
337+
buf ~= "str";
338+
assert(buf.data == "cstr");
339+
340+
buf.popBackN(2);
341+
assert(buf.data == "cs");
342+
}
343+
329344
///
330345
struct UnsafeArrayBuffer(T)
331346
{

0 commit comments

Comments
 (0)