From 865561fac8fa50dc6301e8068c433bee6648accb Mon Sep 17 00:00:00 2001 From: Shubhranshu Sanjeev Date: Thu, 9 Jan 2025 17:52:20 +0530 Subject: [PATCH] fix: resolved comments --- crates/frontend/src/logic.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/crates/frontend/src/logic.rs b/crates/frontend/src/logic.rs index 891e7c8c..2834bc76 100644 --- a/crates/frontend/src/logic.rs +++ b/crates/frontend/src/logic.rs @@ -16,7 +16,10 @@ pub enum Expression { } pub fn is_variable(v: &serde_json::Value) -> bool { - v.is_object() && v.as_object().unwrap().contains_key("var") + v.is_object() + && v.as_object() + .map(|v| v.contains_key("var")) + .unwrap_or_default() } pub fn is_constant(v: &serde_json::Value) -> bool { @@ -33,7 +36,7 @@ impl Expression { .cloned() .ok_or("Invalid operands list for context")?; - let operand_0 = operands.first(); + let operand_0 = operands.get(0); let operand_1 = operands.get(1); let operand_2 = operands.get(2); @@ -176,6 +179,9 @@ impl From<(SchemaType, Operator)> for Expression { } } +/// The `Operator` enum is just a marker to helps dynamically determine the +/// type of input field to render and the appropriate parsing logic to +/// apply based on the operator type. #[derive(Debug, Clone, Serialize, Deserialize, PartialEq)] pub enum Operator { Is,