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

Fix issue 21199: call unaryFun!fun in Nullable.apply to support string parameter. #7606

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 10 additions & 2 deletions std/typecons.d
Expand Up @@ -3973,11 +3973,11 @@ template apply(alias fun)
{
static if (MustWrapReturn)
{
return fun(t.get).nullable;
return unaryFun!fun(t.get).nullable;
}
else
{
return fun(t.get);
return unaryFun!fun(t.get);
}
}
else
Expand Down Expand Up @@ -4048,6 +4048,14 @@ unittest
S[] array = Nullable!(S[])().get(S[].init);
}

// regression test for https://issues.dlang.org/show_bug.cgi?id=21199
@safe @nogc nothrow pure
unittest
{
struct S { int i; }
assert(S(5).nullable.apply!"a.i" == 5);
}

/**
Just like `Nullable!T`, except that the object refers to a value
sitting elsewhere in memory. This makes assignments overwrite the
Expand Down