Skip to content

Commit

Permalink
Merge #463
Browse files Browse the repository at this point in the history
463: embedded-hal: digital: add #[inline] hints for PinState functions r=Dirbaio a=luojia65

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.

Co-authored-by: Luo Jia / Zhouqi Jiang <luojia@hust.edu.cn>
  • Loading branch information
bors[bot] and luojia65 committed May 31, 2023
2 parents 30a8190 + d500bfa commit 7e24e0c
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions embedded-hal/src/digital.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ pub enum PinState {
}

impl From<bool> for PinState {
#[inline]
fn from(value: bool) -> Self {
match value {
false => PinState::Low,
Expand All @@ -93,6 +94,7 @@ impl From<bool> for PinState {
impl Not for PinState {
type Output = PinState;

#[inline]
fn not(self) -> Self::Output {
match self {
PinState::High => PinState::Low,
Expand All @@ -102,6 +104,7 @@ impl Not for PinState {
}

impl From<PinState> for bool {
#[inline]
fn from(value: PinState) -> bool {
match value {
PinState::Low => false,
Expand Down

0 comments on commit 7e24e0c

Please sign in to comment.