From bd2ba3d567c2830445fd52184003dd1b11f46ed1 Mon Sep 17 00:00:00 2001 From: embr Date: Sat, 3 May 2025 14:42:04 +0200 Subject: [PATCH 1/2] error: Implement core::error::Error Closes #111 --- src/error.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/error.rs b/src/error.rs index 1b68c2e..f16fc02 100644 --- a/src/error.rs +++ b/src/error.rs @@ -1,7 +1,7 @@ use core::fmt::{self, Display}; -use core::result; +use core::{error, result}; #[cfg(feature = "std")] -use std::{error, io}; +use std::io; #[derive(Debug)] /// A custom Scroll error @@ -26,14 +26,15 @@ pub enum Error { IO(io::Error), } -#[cfg(feature = "std")] impl error::Error for Error { fn description(&self) -> &str { match self { Error::TooBig { .. } => "TooBig", Error::BadOffset(_) => "BadOffset", Error::BadInput { .. } => "BadInput", + #[cfg(feature = "std")] Error::Custom(_) => "Custom", + #[cfg(feature = "std")] Error::IO(_) => "IO", } } @@ -42,7 +43,9 @@ impl error::Error for Error { Error::TooBig { .. } => None, Error::BadOffset(_) => None, Error::BadInput { .. } => None, + #[cfg(feature = "std")] Error::Custom(_) => None, + #[cfg(feature = "std")] Error::IO(ref io) => io.source(), } } From f3242ecb058df9961220ff60809938d2b6952692 Mon Sep 17 00:00:00 2001 From: embr Date: Sat, 3 May 2025 14:45:01 +0200 Subject: [PATCH 2/2] build: Raise MSRV to 1.81 for core::error::Error --- .github/workflows/main.yml | 2 +- Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index b79f397..07d9560 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -15,7 +15,7 @@ jobs: include: - build: MSRV # Minimum supported Rust version, ensure it matches the rust-version in Cargo.toml os: ubuntu-latest - rust: 1.63 + rust: 1.81 - build: stable os: ubuntu-latest rust: stable diff --git a/Cargo.toml b/Cargo.toml index e0b9e5c..9a6f6f5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,7 +10,7 @@ license = "MIT" documentation = "https://docs.rs/scroll" description = "A suite of powerful, extensible, generic, endian-aware Read/Write traits for byte buffers" include = ["src/**/*", "Cargo.toml", "LICENSE", "README.md"] -rust-version = "1.63" +rust-version = "1.81" [features] default = ["std"]