Skip to content

Commit cb1f73e

Browse files
authored
Merge pull request #718 from t-wallet/spi-device-error-into-infallible
Implement Into<Infallible> when spi::DeviceError is infallible
2 parents 4e653a7 + 19802b3 commit cb1f73e

File tree

1 file changed

+10
-0
lines changed
  • embedded-hal-bus/src/spi

1 file changed

+10
-0
lines changed

embedded-hal-bus/src/spi/mod.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
//! `SpiDevice` implementations.
22
3+
use core::convert::Infallible;
34
use core::fmt::{self, Debug, Display, Formatter};
45
use embedded_hal::spi::{Error, ErrorKind};
56

@@ -63,6 +64,15 @@ where
6364
}
6465
}
6566

67+
impl From<DeviceError<Infallible, Infallible>> for Infallible {
68+
fn from(value: DeviceError<Infallible, Infallible>) -> Self {
69+
match value {
70+
DeviceError::Spi(e) => e,
71+
DeviceError::Cs(e) => e,
72+
}
73+
}
74+
}
75+
6676
/// Dummy [`DelayNs`](embedded_hal::delay::DelayNs) implementation that panics on use.
6777
#[derive(Copy, Clone, Eq, PartialEq, Debug)]
6878
#[cfg_attr(feature = "defmt-03", derive(defmt::Format))]

0 commit comments

Comments
 (0)