Skip to content

Commit fc4d6da

Browse files
authored
Merge pull request #2 from w3irdrobot/core-error
impl core::error::Error under a feature
2 parents ff8c7fd + c7fb85a commit fc4d6da

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ maybe-async-cfg = "0.2"
2020

2121
[features]
2222
async = ["dep:embedded-hal-async"]
23+
core-error = [] # bump MSRV to 1.81.0
2324
default = ["sync"]
2425
defmt-03 = ["dep:defmt"]
2526
not-recommended-rfs = []

src/error.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,13 @@ pub enum Error<E> {
1616
/// Try to set a Current value without giving the Rfs value
1717
UnknownRfs,
1818
}
19+
20+
#[cfg(feature = "core-error")]
21+
impl<E: core::fmt::Debug> core::error::Error for Error<E> {}
22+
23+
#[cfg(feature = "core-error")]
24+
impl<E: core::fmt::Debug> core::fmt::Display for Error<E> {
25+
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
26+
write!(f, "{self:?}")
27+
}
28+
}

0 commit comments

Comments
 (0)