mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-30 01:26:15 +02:00
Installable::getCursors: Cleanup
- Clarify doc comments, Installables::getCursors returns non-empty vector - Use vector::at in Installable::getCursor instead of checking for empty vector and throwing an exception with error message.
This commit is contained in:
parent
b26562c629
commit
377d5eb388
2 changed files with 9 additions and 6 deletions
|
@ -379,10 +379,9 @@ Installable::getCursors(EvalState & state)
|
|||
ref<eval_cache::AttrCursor>
|
||||
Installable::getCursor(EvalState & state)
|
||||
{
|
||||
auto cursors = getCursors(state);
|
||||
if (cursors.empty())
|
||||
throw Error("cannot find flake attribute '%s'", what());
|
||||
return cursors[0];
|
||||
/* Although getCursors should return at least one element, in case it doesn't,
|
||||
bound check to avoid an undefined behavior for vector[0] */
|
||||
return getCursors(state).at(0);
|
||||
}
|
||||
|
||||
static StorePath getDeriver(
|
||||
|
|
|
@ -103,9 +103,13 @@ struct Installable
|
|||
return {};
|
||||
}
|
||||
|
||||
/* Get a cursor to each value this Installable could refer to. However
|
||||
if none exists, throw exception instead of returning empty vector. */
|
||||
virtual std::vector<ref<eval_cache::AttrCursor>>
|
||||
getCursors(EvalState & state);
|
||||
|
||||
/* Get the first and most preferred cursor this Installable could refer
|
||||
to, or throw an exception if none exists. */
|
||||
virtual ref<eval_cache::AttrCursor>
|
||||
getCursor(EvalState & state);
|
||||
|
||||
|
@ -193,8 +197,8 @@ struct InstallableFlake : InstallableValue
|
|||
|
||||
std::pair<Value *, PosIdx> toValue(EvalState & state) override;
|
||||
|
||||
/* Get a cursor to every attrpath in getActualAttrPaths() that
|
||||
exists. */
|
||||
/* Get a cursor to every attrpath in getActualAttrPaths()
|
||||
that exists. However if none exists, throw an exception. */
|
||||
std::vector<ref<eval_cache::AttrCursor>>
|
||||
getCursors(EvalState & state) override;
|
||||
|
||||
|
|
Loading…
Reference in a new issue