This commit is contained in:
Simon Gardling 2022-02-17 14:42:10 -05:00
parent d63af25774
commit 9b46d9d79e
2 changed files with 5 additions and 7 deletions

View File

@ -66,11 +66,11 @@ impl ChartManager {
// Tests function to make sure it's able to be parsed. Returns the string of the Error produced, or an empty string if it runs successfully.
pub fn test_func(function_string: String) -> String {
// Factorials do not work, and it would be really difficult to make them work
if function_string.contains("!") {
if function_string.contains('!') {
return "Factorials are unsupported".to_string();
}
let new_func_str: String = add_asterisks(function_string.clone());
let new_func_str: String = add_asterisks(function_string);
let expr_result = new_func_str.parse();
let expr_error = match &expr_result {
Ok(_) => "".to_string(),

View File

@ -72,10 +72,8 @@ pub fn add_asterisks(function_in: String) -> String {
{
add_asterisk = true;
}
} else if numbers.contains(&c) {
if letters.contains(&prev_char) | prev_pi {
add_asterisk = true;
}
} else if numbers.contains(&c) && letters.contains(&prev_char) | prev_pi {
add_asterisk = true;
}
if add_asterisk {
@ -86,7 +84,7 @@ pub fn add_asterisks(function_in: String) -> String {
output_string += &c.to_string();
}
return output_string;
output_string
}
/// Result of screen to chart coordinates conversion.