From 158f4d1d69fc77e594866fa5d78b45c6daa66ff0 Mon Sep 17 00:00:00 2001 From: Aaqa Ishtyaq Date: Wed, 11 Jan 2023 01:03:27 +0530 Subject: fix(tvix/eval): len_without_is_empty clippy warn 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 Reviewed-on: https://cl.tvl.fyi/c/depot/+/7806 Reviewed-by: flokli Tested-by: BuildkiteCI --- tvix/eval/src/value/attrs.rs | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'tvix/eval/src/value/attrs.rs') diff --git a/tvix/eval/src/value/attrs.rs b/tvix/eval/src/value/attrs.rs index d413f0073f..6515fb515a 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) -- cgit 1.4.1