More @safe Node and Node.Pair.

This commit is contained in:
Kiith-Sa 2012-12-27 21:50:53 +01:00
parent d6617f327f
commit 900bd51d52

View file

@ -158,6 +158,19 @@ struct Node
return cmp!(Yes.useTag)(rhs) == 0;
}
/// Assignment (shallow copy) by value.
void opAssign(Pair rhs) @safe
{
opAssign(rhs);
}
/// Assignment (shallow copy) by reference.
void opAssign(ref Pair rhs) @safe
{
key = rhs.key;
value = rhs.value;
}
private:
/*
* Comparison with another Pair.
@ -875,6 +888,30 @@ struct Node
assert(mapNan.containsKey(double.nan));
}
/// Assignment (shallow copy) by value.
void opAssign(Node rhs) @safe
{
opAssign(rhs);
}
/// Assignment (shallow copy) by reference.
void opAssign(ref Node rhs) @safe
{
value_ = rhs.value_;
startMark_ = rhs.startMark_;
tag_ = rhs.tag_;
scalarStyle = rhs.scalarStyle;
collectionStyle = rhs.collectionStyle;
}
// Unittest for opAssign().
unittest
{
auto seq = Node([1, 2, 3, 4, 5]);
auto assigned = seq;
assert(seq == assigned,
"Node.opAssign() doesn't produce an equivalent copy");
}
/**
* Set element at specified index in a collection.
*