From 2dd2b844c72a3b8af2671651b7d59e50f6e1b048 Mon Sep 17 00:00:00 2001 From: Vincent Ambo Date: Thu, 2 Nov 2023 18:43:43 +0300 Subject: chore(tvix/eval): add a marker for sorted borrowed attrs iteration Similar to `into_iter_sorted`, add a marker function for call sites that want *borrowed* sorted iteration. Change-Id: I7c6f14e1ac43fdb14b861b3da183eb5d12bba139 Reviewed-on: https://cl.tvl.fyi/c/depot/+/9899 Autosubmit: tazjin Reviewed-by: flokli Tested-by: BuildkiteCI --- tvix/eval/src/value/attrs.rs | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'tvix/eval/src/value') diff --git a/tvix/eval/src/value/attrs.rs b/tvix/eval/src/value/attrs.rs index 15a709730c..f3638e69c2 100644 --- a/tvix/eval/src/value/attrs.rs +++ b/tvix/eval/src/value/attrs.rs @@ -299,6 +299,12 @@ impl NixAttrs { }) } + /// Same as iter(), but marks call sites which rely on the + /// iteration being lexicographic. + pub fn iter_sorted<'a>(&'a self) -> Iter> { + self.iter() + } + pub fn into_iter(self) -> IntoIter { match self.0 { AttrsRep::Empty => IntoIter(IntoIterRepr::Empty), -- cgit 1.4.1