Skip to content

Commit

Permalink
feat: add 'core-error' feature (#19)
Browse files Browse the repository at this point in the history
  • Loading branch information
DaniPopes authored Nov 28, 2024
1 parent 7b43bc0 commit 3e38e09
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
4 changes: 4 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ default = ["std"]
std = ["hex?/std", "serde?/std", "proptest?/std", "alloc"]
alloc = ["hex?/alloc", "serde?/alloc", "proptest?/alloc"]

# Enables `core::error::Error` implementations always instead of conditionally through `std`.
# Requires Rust 1.81 or newer.
core-error = []

# Serde support. Use with `#[serde(with = "const_hex")]`.
serde = ["hex?/serde", "dep:serde"]

Expand Down
4 changes: 3 additions & 1 deletion src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ pub enum FromHexError {
InvalidStringLength,
}

#[cfg(feature = "std")]
#[cfg(feature = "core-error")]
impl core::error::Error for FromHexError {}
#[cfg(all(feature = "std", not(feature = "core-error")))]
impl std::error::Error for FromHexError {}

impl fmt::Display for FromHexError {
Expand Down

0 comments on commit 3e38e09

Please sign in to comment.