From d500bfa66158d9ee692dfa7fff5ac585b74b7a4f Mon Sep 17 00:00:00 2001 From: Luo Jia / Zhouqi Jiang Date: Wed, 31 May 2023 20:17:50 +0800 Subject: [PATCH] embedded-hal: digital: add #[inline] hints for PinState functions Add inline hints for: - ::not - >::from - >::from Those hints would allow further optimizations if PinState structure functions is used on embedded-hal projects. Signed-off-by: Zhouqi Jiang --- embedded-hal/src/digital.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/embedded-hal/src/digital.rs b/embedded-hal/src/digital.rs index 6292284..c476cb7 100644 --- a/embedded-hal/src/digital.rs +++ b/embedded-hal/src/digital.rs @@ -82,6 +82,7 @@ pub enum PinState { } impl From for PinState { + #[inline] fn from(value: bool) -> Self { match value { false => PinState::Low, @@ -93,6 +94,7 @@ impl From for PinState { impl Not for PinState { type Output = PinState; + #[inline] fn not(self) -> Self::Output { match self { PinState::High => PinState::Low, @@ -102,6 +104,7 @@ impl Not for PinState { } impl From for bool { + #[inline] fn from(value: PinState) -> bool { match value { PinState::Low => false,