From cfc8aa5355cf51f9e8136667b21da6e5d58300bf Mon Sep 17 00:00:00 2001 From: Nick Spinale Date: Thu, 3 Apr 2025 15:52:23 -0700 Subject: [PATCH] Use core::error::Error when available --- num_enum/Cargo.toml | 2 +- num_enum/src/lib.rs | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/num_enum/Cargo.toml b/num_enum/Cargo.toml index 4b8552e..99246f9 100644 --- a/num_enum/Cargo.toml +++ b/num_enum/Cargo.toml @@ -29,11 +29,11 @@ features = ["external_doc"] maintenance = { status = "passively-maintained" } [dependencies] +rustversion = "1.0.4" num_enum_derive = { version = "=0.7.3", path = "../num_enum_derive", default-features = false } [dev-dependencies] anyhow = "1.0.14" paste = "1" -rustversion = "1.0.4" trybuild = "1.0.98" walkdir = "2" diff --git a/num_enum/src/lib.rs b/num_enum/src/lib.rs index 86a0b73..98ab7bf 100644 --- a/num_enum/src/lib.rs +++ b/num_enum/src/lib.rs @@ -81,7 +81,11 @@ impl fmt::Display for TryFromPrimitiveError { } } +#[rustversion::since(1.81)] +impl ::core::error::Error for TryFromPrimitiveError {} + #[cfg(feature = "std")] +#[rustversion::before(1.81)] impl ::std::error::Error for TryFromPrimitiveError {} // This trait exists to try to give a more clear error message when someone attempts to derive both FromPrimitive and TryFromPrimitive.