chore: standardize the error message of a subet of unreachable! calls

This commit is contained in:
Rekai Nyangadzayi Musuka 2021-03-15 23:51:40 -05:00
parent 3b5d94adfc
commit ef4cc8c3b6
3 changed files with 9 additions and 12 deletions

View File

@ -197,7 +197,7 @@ impl From<u8> for GrayShade {
0b01 => GrayShade::LightGray, 0b01 => GrayShade::LightGray,
0b10 => GrayShade::DarkGray, 0b10 => GrayShade::DarkGray,
0b11 => GrayShade::Black, 0b11 => GrayShade::Black,
_ => unreachable!("{:#04X} is not a valid Shade of Gray", byte), _ => unreachable!("{:#04X} is not a valid value for GrayShade", byte),
} }
} }
} }

View File

@ -96,7 +96,7 @@ impl From<u8> for FrequencyType {
match byte { match byte {
0b00 => Self::Counter, 0b00 => Self::Counter,
0b01 => Self::Consecutive, 0b01 => Self::Consecutive,
_ => unreachable!("{} is not a valid number for FrequencyType"), _ => unreachable!("{:#04X} is not a valid value for FrequencyType"),
} }
} }
} }
@ -194,10 +194,7 @@ impl From<u8> for EnvelopeDirection {
match byte { match byte {
0b00 => Self::Decrease, 0b00 => Self::Decrease,
0b01 => Self::Increase, 0b01 => Self::Increase,
_ => unreachable!( _ => unreachable!("{:#04X} is not a valid value for EnvelopeDirection", byte),
"{:#04X} is not a possible value for EnvelopeDirection",
byte
),
} }
} }
} }
@ -267,7 +264,7 @@ impl From<u8> for WavePattern {
0b01 => Self::OneQuarter, 0b01 => Self::OneQuarter,
0b10 => Self::OneHalf, 0b10 => Self::OneHalf,
0b11 => Self::ThreeQuarters, 0b11 => Self::ThreeQuarters,
_ => unreachable!("{:#04X} is not a valid value for a Sound Wave", byte), _ => unreachable!("{:#04X} is not a valid value for WavePattern", byte),
} }
} }
} }

View File

@ -32,11 +32,11 @@ pub enum TimerSpeed {
impl From<u8> for TimerSpeed { impl From<u8> for TimerSpeed {
fn from(byte: u8) -> Self { fn from(byte: u8) -> Self {
match byte { match byte {
0x00 => Self::Freq4096Hz, 0b00 => Self::Freq4096Hz,
0x01 => Self::Freq262144Hz, 0b01 => Self::Freq262144Hz,
0x10 => Self::Freq65536Hz, 0b10 => Self::Freq65536Hz,
0x11 => Self::Freq16384Hz, 0b11 => Self::Freq16384Hz,
_ => unreachable!("{:04X} is not a valid representation of TimerSpeed", byte), _ => unreachable!("{:#04X} is not a valid value for TimerSpeed", byte),
} }
} }
} }