From 1a8506c04fa92db4ad0a57c4dc0f7a03a3eccb0c Mon Sep 17 00:00:00 2001 From: Rekai Musuka Date: Mon, 15 Mar 2021 22:36:27 -0500 Subject: [PATCH] chore: improve code quality --- src/sound.rs | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/src/sound.rs b/src/sound.rs index 4ad301c..2c668bb 100644 --- a/src/sound.rs +++ b/src/sound.rs @@ -240,19 +240,6 @@ impl From for u8 { } } -impl From for u8 { - fn from(pattern: WavePattern) -> Self { - use WavePattern::*; - - match pattern { - OneEighth => 0b00, - OneQuarter => 0b01, - OneHalf => 0b10, - ThreeQuarters => 0b11, - } - } -} - #[derive(Debug, Clone, Copy)] pub enum WavePattern { OneEighth = 0, // 12.5% ( _-------_-------_------- ) @@ -267,6 +254,12 @@ impl Default for WavePattern { } } +impl From for u8 { + fn from(pattern: WavePattern) -> Self { + pattern as u8 + } +} + impl From for WavePattern { fn from(byte: u8) -> Self { match byte {