diff --git a/src/controller/view_utils/hamming_code_input_utils.rs b/src/controller/view_utils/hamming_code_input_utils.rs index 03e7f69..2113fd0 100644 --- a/src/controller/view_utils/hamming_code_input_utils.rs +++ b/src/controller/view_utils/hamming_code_input_utils.rs @@ -23,19 +23,13 @@ pub fn start_hamming_algorithm(input: &TextView, output: &TextView, mode: bool) Ok(res) => output.buffer().set_text(res.trim_end()), Err(rej) => output.buffer().set_text(rej.as_str()), } + hamming(parsed_input, operation) } -pub fn check_correct_binary_code( - input: &String, - prepared_input: &String, - l: usize, -) -> (bool, bool) { - let first_condition: bool = input - .as_str() - .chars() - .all(|c| c == '1' || c == '0' || c == ' '); +pub fn check_correct_binary_code(input: &str, prepared_input: &str, l: usize) -> (bool, bool) { + let first_condition: bool = prepared_input.len() % l == 0; - let second_condition: bool = prepared_input.len() % l == 0; + let second_condition: bool = input.chars().all(|c| c == '1' || c == '0' || c == ' '); (first_condition, second_condition) }