Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge PR #8315 & #8316 in to stable #8318

Merged
merged 2 commits into from
Nov 15, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions std/container/dlist.d
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,12 @@ struct DList(T)

T _payload = T.init;

this (BaseNode _base, T _payload)
{
this._base = _base;
this._payload = _payload;
}

inout(BaseNode)* asBaseNode() inout @trusted
{
return &_base;
Expand Down
31 changes: 29 additions & 2 deletions std/typecons.d
Original file line number Diff line number Diff line change
Expand Up @@ -2792,6 +2792,15 @@ struct Nullable(T)
}
}

this (ref return scope inout Nullable!T rhs) inout
{
_isNull = rhs._isNull;
if (!_isNull)
_value.payload = rhs._value.payload;
else
_value = DontCallDestructorT.init;
}

/**
* If they are both null, then they are equal. If one is null and the other
* is not, then they are not equal. If they are both non-null, then they are
Expand Down Expand Up @@ -3284,11 +3293,11 @@ auto nullable(T)(T t)
static struct S2 //inspired from 9404
{
Nullable!int ni;
this(S2 other)
this(ref S2 other)
{
ni = other.ni;
}
void opAssign(S2 other)
void opAssign(ref S2 other)
{
ni = other.ni;
}
Expand Down Expand Up @@ -9529,3 +9538,21 @@ unittest
assert((a ^ true) == Ternary.no);
assert((a ^ false) == Ternary.yes);
}

// https://issues.dlang.org/show_bug.cgi?id=22511
@safe unittest
{
static struct S
{
int b;
@disable this(this);
this (ref return scope inout S rhs) inout
{
this.b = rhs.b + 1;
}
}

Nullable!S s1 = S(1);
Nullable!S s2 = s1;
assert(s2.get().b > s1.get().b);
}