From ef4cc8c3b613c349b44ff6df993e24f6f9cf60b1 Mon Sep 17 00:00:00 2001 From: Rekai Musuka Date: Mon, 15 Mar 2021 23:51:40 -0500 Subject: [PATCH] chore: standardize the error message of a subet of unreachable! calls --- src/ppu.rs | 2 +- src/sound.rs | 9 +++------ src/timer.rs | 10 +++++----- 3 files changed, 9 insertions(+), 12 deletions(-) diff --git a/src/ppu.rs b/src/ppu.rs index b095157..bd20ab3 100644 --- a/src/ppu.rs +++ b/src/ppu.rs @@ -197,7 +197,7 @@ impl From for GrayShade { 0b01 => GrayShade::LightGray, 0b10 => GrayShade::DarkGray, 0b11 => GrayShade::Black, - _ => unreachable!("{:#04X} is not a valid Shade of Gray", byte), + _ => unreachable!("{:#04X} is not a valid value for GrayShade", byte), } } } diff --git a/src/sound.rs b/src/sound.rs index 2c668bb..7669070 100644 --- a/src/sound.rs +++ b/src/sound.rs @@ -96,7 +96,7 @@ impl From for FrequencyType { match byte { 0b00 => Self::Counter, 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 for EnvelopeDirection { match byte { 0b00 => Self::Decrease, 0b01 => Self::Increase, - _ => unreachable!( - "{:#04X} is not a possible value for EnvelopeDirection", - byte - ), + _ => unreachable!("{:#04X} is not a valid value for EnvelopeDirection", byte), } } } @@ -267,7 +264,7 @@ impl From for WavePattern { 0b01 => Self::OneQuarter, 0b10 => Self::OneHalf, 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), } } } diff --git a/src/timer.rs b/src/timer.rs index a1838bd..4d452d0 100644 --- a/src/timer.rs +++ b/src/timer.rs @@ -32,11 +32,11 @@ pub enum TimerSpeed { impl From for TimerSpeed { fn from(byte: u8) -> Self { match byte { - 0x00 => Self::Freq4096Hz, - 0x01 => Self::Freq262144Hz, - 0x10 => Self::Freq65536Hz, - 0x11 => Self::Freq16384Hz, - _ => unreachable!("{:04X} is not a valid representation of TimerSpeed", byte), + 0b00 => Self::Freq4096Hz, + 0b01 => Self::Freq262144Hz, + 0b10 => Self::Freq65536Hz, + 0b11 => Self::Freq16384Hz, + _ => unreachable!("{:#04X} is not a valid value for TimerSpeed", byte), } } }