1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-07-06 21:41:48 +02:00

More designated initializers

This commit is contained in:
John Ericson 2020-06-19 17:42:56 +00:00
parent 2f0e395c99
commit 911fc88bcb
6 changed files with 19 additions and 10 deletions

View file

@ -55,10 +55,16 @@ ContentAddress parseContentAddress(std::string_view rawCa) {
auto methodAndHash = rawCa.substr(prefixSeparator+1, string::npos);
if (methodAndHash.substr(0,2) == "r:") {
std::string_view hashRaw = methodAndHash.substr(2,string::npos);
return FixedOutputHash { FileIngestionMethod::Recursive, Hash(string(hashRaw)) };
return FixedOutputHash {
.method = FileIngestionMethod::Recursive,
.hash = Hash(string(hashRaw)),
};
} else {
std::string_view hashRaw = methodAndHash;
return FixedOutputHash { FileIngestionMethod::Flat, Hash(string(hashRaw)) };
return FixedOutputHash {
.method = FileIngestionMethod::Flat,
.hash = Hash(string(hashRaw)),
};
}
} else {
throw Error("parseContentAddress: format not recognized; has to be text or fixed");