Skip to content

Commit

Permalink
remove duplicated code
Browse files Browse the repository at this point in the history
  • Loading branch information
lovasoa committed Mar 14, 2022
1 parent af77f17 commit 65bf8ad
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions src/function/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,11 +123,8 @@ pub fn builtin_function(identifier: &str) -> Option<Function> {
})),
"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() {
Expand Down

0 comments on commit 65bf8ad

Please sign in to comment.