Skip to content

Commit f786adf

Browse files
committed
fix appender and variant
1 parent ad324a2 commit f786adf

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

source/mir/appender.d

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ private extern(C) @system nothrow @nogc pure void* memcpy(scope void* s1, scope
2626
struct ScopedBuffer(T, size_t bytes = 4096)
2727
if (bytes)
2828
{
29-
import std.traits: Unqual, isIterable, hasElaborateAssign, isAssignable, isArray;
29+
import std.traits: Unqual, isMutable, isIterable, hasElaborateAssign, isAssignable, isArray;
3030
import mir.primitives: hasLength;
3131
import mir.conv: emplaceRef;
3232

@@ -94,11 +94,19 @@ struct ScopedBuffer(T, size_t bytes = 4096)
9494
}
9595

9696
///
97-
void put(R e) @safe scope
97+
void put(T e) @safe scope
9898
{
9999
auto cl = _currentLength;
100100
prepare(1);
101-
emplaceRef!(Unqual!T)(data[cl], e);
101+
static if (isMutable!T)
102+
{
103+
import core.lifetime: move;
104+
emplaceRef!(Unqual!T)(data[cl], e.move);
105+
}
106+
else
107+
{
108+
emplaceRef!(Unqual!T)(data[cl], e);
109+
}
102110
}
103111

104112
static if (T.sizeof > 8 || hasElaborateAssign!T)

source/mir/variant.d

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ struct Variant(Types...)
3434
private enum hasDestructor = anySatisfy!(hasElaborateDestructor, Types);
3535

3636
static if (hasDestructor)
37-
~this()
37+
~this() @safe
3838
{
3939
S: switch (type)
4040
{

0 commit comments

Comments
 (0)