mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-26 07:46:21 +02:00
Use switch statement instead of sequence of ifs
This commit is contained in:
parent
93f1678ec6
commit
ba0f841a07
1 changed files with 13 additions and 9 deletions
|
@ -120,15 +120,19 @@ static FlakeInput parseFlakeInput(EvalState & state,
|
|||
expectType(state, nString, *attr.value, *attr.pos);
|
||||
input.follows = parseInputPath(attr.value->string.s);
|
||||
} else {
|
||||
if (attr.value->type() == nString) {
|
||||
attrs.emplace(attr.name, attr.value->string.s);
|
||||
} else if (attr.value->type() == nBool) {
|
||||
attrs.emplace(attr.name, Explicit<bool>{ attr.value->boolean });
|
||||
} else if (attr.value->type() == nInt) {
|
||||
attrs.emplace(attr.name, attr.value->integer);
|
||||
} else {
|
||||
throw TypeError("flake input attribute '%s' is %s while a string, boolean, or integer is expected",
|
||||
attr.name, showType(*attr.value));
|
||||
switch (attr.value->type()) {
|
||||
case nString:
|
||||
attrs.emplace(attr.name, attr.value->string.s);
|
||||
break;
|
||||
case nBool:
|
||||
attrs.emplace(attr.name, Explicit<bool> { attr.value->boolean });
|
||||
break;
|
||||
case nInt:
|
||||
attrs.emplace(attr.name, attr.value->integer);
|
||||
break;
|
||||
default:
|
||||
throw TypeError("flake input attribute '%s' is %s while a string, boolean, or integer is expected",
|
||||
attr.name, showType(*attr.value));
|
||||
}
|
||||
}
|
||||
} catch (Error & e) {
|
||||
|
|
Loading…
Reference in a new issue