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| {
|
"if" => Some(Function::new(|argument| {
|
||||||
let mut arguments = argument.as_fixed_len_tuple(3)?;
|
let mut arguments = argument.as_fixed_len_tuple(3)?;
|
||||||
Ok(if arguments[0].as_boolean()? {
|
let result_index = if arguments[0].as_boolean()? { 1 } else { 2 };
|
||||||
arguments.swap_remove(1)
|
Ok(arguments.swap_remove(result_index))
|
||||||
} else {
|
|
||||||
arguments.swap_remove(2)
|
|
||||||
})
|
|
||||||
})),
|
})),
|
||||||
"len" => Some(Function::new(|argument| {
|
"len" => Some(Function::new(|argument| {
|
||||||
if let Ok(subject) = argument.as_string() {
|
if let Ok(subject) = argument.as_string() {
|
||||||
|
Loading…
Reference in New Issue
Block a user