mirror of
https://github.com/dlang/phobos.git
synced 2025-04-29 14:40:30 +03:00
ChooseResult: use of unions need to be @trusted
This commit is contained in:
parent
4d891a94f4
commit
a7a847013e
1 changed files with 17 additions and 2 deletions
|
@ -1450,9 +1450,15 @@ private struct ChooseResult(R1, R2)
|
|||
auto ref ExtraArgs extraArgs)
|
||||
{
|
||||
if (r.r1Chosen)
|
||||
return foo(r.r1, extraArgs);
|
||||
{
|
||||
ref get1(return ref ChooseResult r) @trusted { return r.r1; }
|
||||
return foo(get1(r), extraArgs);
|
||||
}
|
||||
else
|
||||
return foo(r.r2, extraArgs);
|
||||
{
|
||||
ref get2(return ref ChooseResult r) @trusted { return r.r2; }
|
||||
return foo(get2(r), extraArgs);
|
||||
}
|
||||
}
|
||||
|
||||
this(bool r1Chosen, return scope R1 r1, return scope R2 r2) @trusted
|
||||
|
@ -1475,6 +1481,15 @@ private struct ChooseResult(R1, R2)
|
|||
}
|
||||
}
|
||||
|
||||
void opAssign(return scope ChooseResult r) @trusted
|
||||
{
|
||||
r1Chosen = r.r1Chosen;
|
||||
if (r1Chosen)
|
||||
r1 = r.r1; // assigning to union members is @system
|
||||
else
|
||||
r2 = r.r2;
|
||||
}
|
||||
|
||||
// Carefully defined postblit to postblit the appropriate range
|
||||
static if (hasElaborateCopyConstructor!R1
|
||||
|| hasElaborateCopyConstructor!R2)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue