From 65bf8adc9cb5cb46ca5ae5bc35da66c6971862cc Mon Sep 17 00:00:00 2001 From: Ophir LOJKINE Date: Mon, 14 Mar 2022 16:08:08 +0100 Subject: [PATCH] remove duplicated code --- src/function/builtin.rs | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/function/builtin.rs b/src/function/builtin.rs index 04b50b7..7194da1 100644 --- a/src/function/builtin.rs +++ b/src/function/builtin.rs @@ -123,11 +123,8 @@ pub fn builtin_function(identifier: &str) -> Option { })), "if" => Some(Function::new(|argument| { let mut arguments = argument.as_fixed_len_tuple(3)?; - Ok(if arguments[0].as_boolean()? { - arguments.swap_remove(1) - } else { - arguments.swap_remove(2) - }) + let result_index = if arguments[0].as_boolean()? { 1 } else { 2 }; + Ok(arguments.swap_remove(result_index)) })), "len" => Some(Function::new(|argument| { if let Ok(subject) = argument.as_string() {