Skip to content

Commit

Permalink
impl core::error::Error under a feature
Browse files Browse the repository at this point in the history
  • Loading branch information
georgesFoundation committed Nov 20, 2024
1 parent ded401b commit 621f7dc
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
3 changes: 2 additions & 1 deletion stratum-v1/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,11 @@ serde = { workspace = true }
serde-json-core = { workspace = true, features = ["custom-error-messages"] }

[features]
core-error = [] # bump MSRV to 1.81.0
defmt-03 = [
"dep:defmt",
"embedded-io-async/defmt-03",
# "faster-hex/defmt-03", # will enable it after faster-hex publish PR#54
# "faster-hex/defmt-03", # will enable it after faster-hex publish 0.11
"heapless/defmt-03",
"serde-json-core/defmt",
]
Expand Down
6 changes: 4 additions & 2 deletions stratum-v1/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,11 @@ pub enum Error {
HexError(faster_hex::Error),
}

// impl core::error::Error for Error {}
#[cfg(feature = "core-error")]
impl<E: core::fmt::Debug> core::error::Error for Error<E> {}

impl core::fmt::Display for Error {
#[cfg(feature = "core-error")]
impl<E: core::fmt::Debug> core::fmt::Display for Error<E> {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
write!(f, "{self:?}")
}
Expand Down

0 comments on commit 621f7dc

Please sign in to comment.