remove duplicated code
This commit is contained in:
parent
af77f1703e
commit
65bf8adc9c
@ -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() {
|
||||
|
Loading…
Reference in New Issue
Block a user