aboutsummaryrefslogtreecommitdiff
path: root/src/libexpr/attr-set.hh
diff options
context:
space:
mode:
Diffstat (limited to 'src/libexpr/attr-set.hh')
-rw-r--r--src/libexpr/attr-set.hh9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/libexpr/attr-set.hh b/src/libexpr/attr-set.hh
index 3119a1848..6c5fb21ad 100644
--- a/src/libexpr/attr-set.hh
+++ b/src/libexpr/attr-set.hh
@@ -4,6 +4,7 @@
#include "symbol-table.hh"
#include <algorithm>
+#include <optional>
namespace nix {
@@ -63,6 +64,14 @@ public:
return end();
}
+ std::optional<Attr *> get(const Symbol & name)
+ {
+ Attr key(name, 0);
+ iterator i = std::lower_bound(begin(), end(), key);
+ if (i != end() && i->name == name) return &*i;
+ return {};
+ }
+
iterator begin() { return &attrs[0]; }
iterator end() { return &attrs[size_]; }