about summary refs log tree commit diff
path: root/tvix/eval/src/value
diff options
context:
space:
mode:
authorAaqa Ishtyaq <aaqaishtyaq@gmail.com>2023-01-10T19·33+0530
committerclbot <clbot@tvl.fyi>2023-01-12T18·06+0000
commit158f4d1d69fc77e594866fa5d78b45c6daa66ff0 (patch)
tree87e4ef9b9a1a7094e6363d72445982b93f45e3b3 /tvix/eval/src/value
parent09654ffb80623225bc2e8e8562b081888f68cc78 (diff)
fix(tvix/eval): len_without_is_empty clippy warn r/5654
This CL addresses clippy warning len_without_is_empty
which expects `.is_empty()` method to be present when
implementing `.len()` method for an item.

Change-Id: I8878db630b9ef5853649a906b764a33299bb5dc8
Signed-off-by: Aaqa Ishtyaq <aaqaishtyaq@gmail.com>
Reviewed-on: https://cl.tvl.fyi/c/depot/+/7806
Reviewed-by: flokli <flokli@flokli.de>
Tested-by: BuildkiteCI
Diffstat (limited to 'tvix/eval/src/value')
-rw-r--r--tvix/eval/src/value/attrs.rs8
-rw-r--r--tvix/eval/src/value/list.rs4
2 files changed, 12 insertions, 0 deletions
diff --git a/tvix/eval/src/value/attrs.rs b/tvix/eval/src/value/attrs.rs
index d413f0073f26..6515fb515a5d 100644
--- a/tvix/eval/src/value/attrs.rs
+++ b/tvix/eval/src/value/attrs.rs
@@ -301,6 +301,14 @@ impl NixAttrs {
         }
     }
 
+    pub fn is_empty(&self) -> bool {
+        match &self.0 {
+            AttrsRep::Im(map) => map.is_empty(),
+            AttrsRep::Empty => true,
+            AttrsRep::KV { .. } => false,
+        }
+    }
+
     /// Select a value from an attribute set by key.
     pub fn select(&self, key: &str) -> Option<&Value> {
         self.0.select(key)
diff --git a/tvix/eval/src/value/list.rs b/tvix/eval/src/value/list.rs
index 70952419abea..6d830b7283d0 100644
--- a/tvix/eval/src/value/list.rs
+++ b/tvix/eval/src/value/list.rs
@@ -67,6 +67,10 @@ impl NixList {
         self.0.get(i)
     }
 
+    pub fn is_empty(&self) -> bool {
+        self.0.is_empty()
+    }
+
     pub fn construct(count: usize, stack_slice: Vec<Value>) -> Self {
         debug_assert!(
             count == stack_slice.len(),