diff --git a/CHANGELOG.md b/CHANGELOG.md index 4f4af1384..ad4fb44ed 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ## [Unreleased] +### Added +- `Error` traits for Can, SPI, I2C and Serial are implemented for Infallible ## [v1.0.0-alpha.6] - 2021-11-19 diff --git a/src/can/mod.rs b/src/can/mod.rs index f52ddd175..b70212bec 100644 --- a/src/can/mod.rs +++ b/src/can/mod.rs @@ -58,6 +58,12 @@ pub trait Error: core::fmt::Debug { fn kind(&self) -> ErrorKind; } +impl Error for core::convert::Infallible { + fn kind(&self) -> ErrorKind { + match *self {} + } +} + /// CAN error kind /// /// This represents a common set of CAN operation errors. HAL implementations are diff --git a/src/i2c.rs b/src/i2c.rs index 3241481e3..c20fd587d 100644 --- a/src/i2c.rs +++ b/src/i2c.rs @@ -107,6 +107,12 @@ pub trait Error: core::fmt::Debug { fn kind(&self) -> ErrorKind; } +impl Error for core::convert::Infallible { + fn kind(&self) -> ErrorKind { + match *self {} + } +} + /// I2C error kind /// /// This represents a common set of I2C operation errors. HAL implementations are diff --git a/src/serial/mod.rs b/src/serial/mod.rs index e33f45773..c74964483 100644 --- a/src/serial/mod.rs +++ b/src/serial/mod.rs @@ -13,6 +13,12 @@ pub trait Error: core::fmt::Debug { fn kind(&self) -> ErrorKind; } +impl Error for core::convert::Infallible { + fn kind(&self) -> ErrorKind { + match *self {} + } +} + /// Serial error kind /// /// This represents a common set of serial operation errors. HAL implementations are diff --git a/src/spi/mod.rs b/src/spi/mod.rs index c367e70d8..048de49a4 100644 --- a/src/spi/mod.rs +++ b/src/spi/mod.rs @@ -64,6 +64,12 @@ pub trait Error: core::fmt::Debug { fn kind(&self) -> ErrorKind; } +impl Error for core::convert::Infallible { + fn kind(&self) -> ErrorKind { + match *self {} + } +} + /// SPI error kind /// /// This represents a common set of SPI operation errors. HAL implementations are