From 6c7ecfb694acf607868c4567285902d0c5013289 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20J=C3=B6rdens?= Date: Tue, 1 Oct 2024 12:34:44 +0200 Subject: [PATCH 1/3] impl core::error::Error for Error --- CHANGELOG.md | 4 ++++ Cargo.toml | 1 + src/lib.rs | 8 ++++++++ 3 files changed, 13 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3fbcb2c..32952f9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/). * For `Runner::input_byte` the buffer `B` does not need to be `Sized` +### Added + +* `impl core::error::Error for Error` + ## [v0.6.0] - 2024-08-30 ### Changed diff --git a/Cargo.toml b/Cargo.toml index 38465b3..9e4ae68 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,6 +7,7 @@ license = "MIT OR Apache-2.0" edition = "2021" repository = "https://github.com/rust-embedded-community/menu" readme = "README.md" +rust-version = "1.81.0" [dependencies] embedded-io = "0.6.1" diff --git a/src/lib.rs b/src/lib.rs index 00159c4..cdaeff4 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -127,6 +127,14 @@ pub enum Error { NotFound, } +impl core::fmt::Display for Error { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + core::fmt::Debug::fmt(self, f) + } +} + +impl core::error::Error for Error {} + /// Looks for the named parameter in the parameter list of the item, then /// finds the correct argument. /// From 71fc02ff38342e2bcf370c74ff35ba71ce163633 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20J=C3=B6rdens?= Date: Wed, 2 Oct 2024 14:08:38 +0200 Subject: [PATCH 2/3] feature gate core::error --- Cargo.toml | 2 +- src/lib.rs | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 9e4ae68..d68a661 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,7 +7,6 @@ license = "MIT OR Apache-2.0" edition = "2021" repository = "https://github.com/rust-embedded-community/menu" readme = "README.md" -rust-version = "1.81.0" [dependencies] embedded-io = "0.6.1" @@ -15,6 +14,7 @@ noline = { version = "0.5.0", optional = true } [features] default = ["echo"] +error-in-core = [] # requires rust 1.81.0 echo = [] [dev-dependencies] diff --git a/src/lib.rs b/src/lib.rs index cdaeff4..4c06d51 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -133,6 +133,7 @@ impl core::fmt::Display for Error { } } +#[cfg(feature = "error-in-core")] impl core::error::Error for Error {} /// Looks for the named parameter in the parameter list of the item, then From 2fe6c19e7ba4d3bd040097b359859c0b6e9c17da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20J=C3=B6rdens?= Date: Wed, 2 Oct 2024 14:10:45 +0200 Subject: [PATCH 3/3] use rustversion to gate core::error --- CHANGELOG.md | 2 +- Cargo.toml | 2 +- src/lib.rs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 32952f9..22ff572 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,7 +13,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ### Added -* `impl core::error::Error for Error` +* `impl core::error::Error for Error` on rust >= 1.81 ## [v0.6.0] - 2024-08-30 diff --git a/Cargo.toml b/Cargo.toml index d68a661..0ef08e3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,10 +11,10 @@ readme = "README.md" [dependencies] embedded-io = "0.6.1" noline = { version = "0.5.0", optional = true } +rustversion = "1.0.17" [features] default = ["echo"] -error-in-core = [] # requires rust 1.81.0 echo = [] [dev-dependencies] diff --git a/src/lib.rs b/src/lib.rs index 4c06d51..e7cfc7d 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -133,7 +133,7 @@ impl core::fmt::Display for Error { } } -#[cfg(feature = "error-in-core")] +#[rustversion::since(1.81)] impl core::error::Error for Error {} /// Looks for the named parameter in the parameter list of the item, then