Skip to content

Implement Error traits for Infallible #328

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 20, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
6 changes: 6 additions & 0 deletions src/can/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions src/i2c.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions src/serial/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions src/spi/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down