SList.opAssign

Assign rhs to this list. The current list will now become another reference to rhs, unless rhs is null, in which case the current list will become empty. If rhs refers to the current list nothing will happen.

All the previous list elements that have no more references to them will be destroyed; this leads to a O(n) complexity.

struct SList(T)
ref
opAssign
()
(
auto ref typeof(this) rhs
)

Parameters

rhs typeof(this)

a reference to a singly linked list

Return Value

Type: auto ref

a reference to this list

Complexity: O(n).

Examples

import std.algorithm.comparison : equal;

auto sl = SList!int(1);
auto sl2 = SList!int(1, 2);

sl = sl2; // this will free the old sl
assert(equal(sl, [1, 2]));
sl.front = 0;
assert(equal(sl2, [0, 2]));

Meta