Fix Issue 22125 - std.process.Config was changed to a struct but miss operator overloads

This commit is contained in:
Vladimir Panteleev 2021-07-14 20:50:27 +00:00
parent 19003dd639
commit baf6ede6de
No known key found for this signature in database
GPG key ID: 5004F0FAD051576D

View file

@ -2131,9 +2131,20 @@ struct Config
enum Config inheritFDs = Config(Flags.inheritFDs); /// ditto
enum Config detached = Config(Flags.detached); /// ditto
enum Config stderrPassThrough = Config(Flags.stderrPassThrough); /// ditto
Config opBinary(string op : "|")(Config other)
Config opUnary(string op)()
if (is(typeof(mixin(op ~ q{flags}))))
{
return Config(flags | other.flags);
return Config(mixin(op ~ q{flags}));
} /// ditto
Config opBinary(string op)(Config other)
if (is(typeof(mixin(q{flags} ~ op ~ q{other.flags}))))
{
return Config(mixin(q{flags} ~ op ~ q{other.flags}));
} /// ditto
Config opOpAssign(string op)(Config other)
if (is(typeof(mixin(q{flags} ~ op ~ q{=other.flags}))))
{
return Config(mixin(q{flags} ~ op ~ q{=other.flags}));
} /// ditto
version (StdDdoc)
@ -2151,6 +2162,16 @@ struct Config
}
}
// https://issues.dlang.org/show_bug.cgi?id=22125
@safe unittest
{
Config c = Config.retainStdin;
c |= Config.retainStdout;
c |= Config.retainStderr;
c &= ~Config.retainStderr;
assert(c == (Config.retainStdin | Config.retainStdout));
}
/// A handle that corresponds to a spawned process.
final class Pid
{