diff --git a/text-compression/src/lib.rs b/text-compression/src/lib.rs index 4866a6c..d56d4b4 100644 --- a/text-compression/src/lib.rs +++ b/text-compression/src/lib.rs @@ -58,7 +58,7 @@ impl ProteinText { let mut bit_array = BitArray::with_capacity(input_string.len(), 5); for (i, c) in input_string.chars().enumerate() { - let char_5bit: u8 = *char_to_5bit.get(&(c as u8)).expect("Input character not in alphabet"); + let char_5bit: u8 = *char_to_5bit.get(&(c as u8)).expect(&format!("Input character '{}' not in alphabet", c)); bit_array.set(i, char_5bit as u64); } @@ -79,7 +79,7 @@ impl ProteinText { let mut bit_array = BitArray::with_capacity(input_vec.len(), 5); for (i, e) in input_vec.iter().enumerate() { - let char_5bit: u8 = *char_to_5bit.get(e).expect("Input character not in alphabet"); + let char_5bit: u8 = *char_to_5bit.get(&(e as u8)).expect(&format!("Input character '{}' not in alphabet", e)); bit_array.set(i, char_5bit as u64); } @@ -131,7 +131,7 @@ impl ProteinText { /// * `index` - The index of the character to change. /// * `value` - The character to fill in as `u8`. pub fn set(&mut self, index: usize, value: u8) { - let char_5bit: u8 = *self.char_to_5bit.get(&value).expect("Input character not in alphabet"); + let char_5bit: u8 = *self.char_to_5bit.get(&value).expect(&format!("Input character '{}' not in alphabet", value)); self.bit_array.set(index, char_5bit as u64); } @@ -477,7 +477,7 @@ mod tests { let mut bit_array = BitArray::with_capacity(input_string.len(), 5); for (i, c) in input_string.chars().enumerate() { - let char_5bit: u8 = *char_to_5bit.get(&(c as u8)).expect("Input character not in alphabet"); + let char_5bit: u8 = *char_to_5bit.get(&(c as u8)).expect(&format!("Input character '{}' not in alphabet", c)); bit_array.set(i, char_5bit as u64); }