simplify test_func
This commit is contained in:
parent
5563679cdf
commit
5e756b0a70
@ -179,17 +179,13 @@ pub fn test_func(function_string: &str) -> Option<String> {
|
|||||||
let var_names = parse_result.unwrap().var_names().to_vec();
|
let var_names = parse_result.unwrap().var_names().to_vec();
|
||||||
|
|
||||||
if var_names != ["x"] {
|
if var_names != ["x"] {
|
||||||
let var_names_not_x: Vec<String> = var_names
|
let var_names_not_x: Vec<&String> = var_names
|
||||||
.iter()
|
.iter()
|
||||||
.filter(|ele| *ele != "x")
|
.filter(|ele| ele != &"x")
|
||||||
.cloned()
|
.collect::<Vec<&String>>();
|
||||||
.collect::<Vec<String>>();
|
|
||||||
|
|
||||||
return match var_names_not_x.len() {
|
return match var_names_not_x.len() {
|
||||||
1 => {
|
1 => Some(format!("Error: invalid variable: {}", var_names_not_x[0])),
|
||||||
let var_name = &var_names_not_x[0];
|
|
||||||
Some(format!("Error: invalid variable: {}", var_name))
|
|
||||||
}
|
|
||||||
_ => Some(format!("Error: invalid variables: {:?}", var_names_not_x)),
|
_ => Some(format!("Error: invalid variables: {:?}", var_names_not_x)),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user