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() {