Skip to content

Commit d500bfa

Browse files
authored
embedded-hal: digital: add #[inline] hints for PinState functions
Add inline hints for: - <PinState as Not>::not - <PinState as From<bool>>::from - <bool as From<PinState>>::from Those hints would allow further optimizations if PinState structure functions is used on embedded-hal projects. Signed-off-by: Zhouqi Jiang <[email protected]>
1 parent 30a8190 commit d500bfa

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

embedded-hal/src/digital.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ pub enum PinState {
8282
}
8383

8484
impl From<bool> for PinState {
85+
#[inline]
8586
fn from(value: bool) -> Self {
8687
match value {
8788
false => PinState::Low,
@@ -93,6 +94,7 @@ impl From<bool> for PinState {
9394
impl Not for PinState {
9495
type Output = PinState;
9596

97+
#[inline]
9698
fn not(self) -> Self::Output {
9799
match self {
98100
PinState::High => PinState::Low,
@@ -102,6 +104,7 @@ impl Not for PinState {
102104
}
103105

104106
impl From<PinState> for bool {
107+
#[inline]
105108
fn from(value: PinState) -> bool {
106109
match value {
107110
PinState::Low => false,

0 commit comments

Comments
 (0)