1
1
Fork 0
mirror of https://github.com/NixOS/nix.git synced 2025-12-06 00:51:00 +01:00

Make it hard to construct an empty OutputsSpec::Names

This should be a non-empty set, and so we don't want people doing this
by accident. We remove the zero-0 constructor with a little inheritance
trickery.
This commit is contained in:
John Ericson 2023-01-11 11:54:43 -05:00
parent 8a3b1b7ced
commit 114a6e2b09
7 changed files with 26 additions and 11 deletions

View file

@ -32,7 +32,7 @@ std::optional<OutputsSpec> OutputsSpec::parseOpt(std::string_view s)
return { OutputsSpec::All {} };
if (match[2].matched)
return { tokenizeString<OutputsSpec::Names>(match[2].str(), ",") };
return OutputsSpec::Names { tokenizeString<StringSet>(match[2].str(), ",") };
assert(false);
}
@ -139,11 +139,11 @@ void to_json(nlohmann::json & json, const ExtendedOutputsSpec & extendedOutputsS
void from_json(const nlohmann::json & json, OutputsSpec & outputsSpec)
{
auto names = json.get<OutputNames>();
if (names == OutputNames({"*"}))
auto names = json.get<StringSet>();
if (names == StringSet({"*"}))
outputsSpec = OutputsSpec::All {};
else
outputsSpec = names;
outputsSpec = OutputsSpec::Names { std::move(names) };
}