From 5e756b0a70bde2fdd22f477dd687644da7f17cce Mon Sep 17 00:00:00 2001 From: Simon Gardling Date: Wed, 30 Mar 2022 09:08:54 -0400 Subject: [PATCH] simplify test_func --- src/parsing.rs | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/parsing.rs b/src/parsing.rs index 46b0f56..344cd7e 100644 --- a/src/parsing.rs +++ b/src/parsing.rs @@ -179,17 +179,13 @@ pub fn test_func(function_string: &str) -> Option { let var_names = parse_result.unwrap().var_names().to_vec(); if var_names != ["x"] { - let var_names_not_x: Vec = var_names + let var_names_not_x: Vec<&String> = var_names .iter() - .filter(|ele| *ele != "x") - .cloned() - .collect::>(); + .filter(|ele| ele != &"x") + .collect::>(); return match var_names_not_x.len() { - 1 => { - let var_name = &var_names_not_x[0]; - Some(format!("Error: invalid variable: {}", var_name)) - } + 1 => Some(format!("Error: invalid variable: {}", var_names_not_x[0])), _ => Some(format!("Error: invalid variables: {:?}", var_names_not_x)), }; }