From 329955f718ac6a99f98856386e8a3708f285de43 Mon Sep 17 00:00:00 2001 From: chemicstry Date: Wed, 13 Jul 2022 02:08:31 +0300 Subject: [PATCH] Use Into conversions instead of matches --- embassy-stm32/src/gpio.rs | 30 ++++++------------------------ 1 file changed, 6 insertions(+), 24 deletions(-) diff --git a/embassy-stm32/src/gpio.rs b/embassy-stm32/src/gpio.rs index b97d5772e..5f0d94b1b 100644 --- a/embassy-stm32/src/gpio.rs +++ b/embassy-stm32/src/gpio.rs @@ -143,10 +143,7 @@ impl<'d, T: Pin> Flex<'d, T> { #[inline] pub fn get_level(&self) -> Level { - match self.is_high() { - true => Level::High, - false => Level::Low, - } + self.is_high().into() } #[inline] @@ -164,10 +161,7 @@ impl<'d, T: Pin> Flex<'d, T> { /// What level output is set to #[inline] pub fn get_set_level(&self) -> Level { - match self.is_set_high() { - true => Level::High, - false => Level::Low, - } + self.is_set_high().into() } #[inline] @@ -309,10 +303,7 @@ impl<'d, T: Pin> Input<'d, T> { #[inline] pub fn get_level(&self) -> Level { - match self.pin.is_high() { - true => Level::High, - false => Level::Low, - } + self.pin.is_high().into() } } @@ -395,10 +386,7 @@ impl<'d, T: Pin> Output<'d, T> { /// What level output is set to #[inline] pub fn get_set_level(&self) -> Level { - match self.pin.is_set_high() { - true => Level::High, - false => Level::Low, - } + self.pin.is_set_high().into() } /// Toggle pin output @@ -440,10 +428,7 @@ impl<'d, T: Pin> OutputOpenDrain<'d, T> { /// Returns current pin level #[inline] pub fn get_level(&self) -> Level { - match self.pin.is_high() { - true => Level::High, - false => Level::Low, - } + self.pin.is_high().into() } /// Set the output as high. @@ -482,10 +467,7 @@ impl<'d, T: Pin> OutputOpenDrain<'d, T> { /// What level output is set to #[inline] pub fn get_set_level(&self) -> Level { - match self.pin.is_set_high() { - true => Level::High, - false => Level::Low, - } + self.pin.is_set_high().into() } /// Toggle pin output