about summary refs log tree commit diff
path: root/tvix/eval/src/value
diff options
context:
space:
mode:
authorVincent Ambo <mail@tazj.in>2022-08-26T15·47+0300
committertazjin <tazjin@tvl.su>2022-09-03T00·49+0000
commit48b0fac76bd1444eac7dd082b699e0ec41fbfdd3 (patch)
treededa025f685c9cc0bc50c2591dae43d4dc280f6c /tvix/eval/src/value
parent7da5076191d4037b9a0cfb5c818d64eb2822d9d0 (diff)
refactor(tvix/eval): slightly more readable AttrsRep::select r/4614
Suggestion from grfn in cl/6158.

Change-Id: I16dcf2296a5ec5d299d5a080ca099b8eda6c254e
Reviewed-on: https://cl.tvl.fyi/c/depot/+/6278
Reviewed-by: grfn <grfn@gws.fyi>
Tested-by: BuildkiteCI
Diffstat (limited to 'tvix/eval/src/value')
-rw-r--r--tvix/eval/src/value/attrs.rs16
1 files changed, 5 insertions, 11 deletions
diff --git a/tvix/eval/src/value/attrs.rs b/tvix/eval/src/value/attrs.rs
index 74f1bd4481b2..922aa0c0d37a 100644
--- a/tvix/eval/src/value/attrs.rs
+++ b/tvix/eval/src/value/attrs.rs
@@ -51,17 +51,11 @@ impl AttrsRep {
         match self {
             AttrsRep::Empty => None,
 
-            AttrsRep::KV { name, value } => {
-                if key == "name" {
-                    return Some(name);
-                }
-
-                if key == "value" {
-                    return Some(value);
-                }
-
-                None
-            }
+            AttrsRep::KV { name, value } => match key {
+                "name" => Some(name),
+                "value" => Some(value),
+                _ => None,
+            },
 
             AttrsRep::Map(map) => map.get(&key.into()),
         }