From cc1381a577bc4cd93dadccccaa50b5f1f4dc0e89 Mon Sep 17 00:00:00 2001 From: Callum Dunster Date: Mon, 13 Nov 2023 16:14:24 +0100 Subject: [PATCH] Add a `NoDetails` variant for `MockError` This allows the creation of errors without any details and removes the dependency on `std` just for errors. --- src/eh0/error.rs | 4 ++++ src/eh1/error.rs | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/src/eh0/error.rs b/src/eh0/error.rs index 43f2e0b..9a7b82d 100644 --- a/src/eh0/error.rs +++ b/src/eh0/error.rs @@ -3,6 +3,9 @@ use std::{error::Error as StdError, fmt, io}; /// Errors that may occur during mocking. #[derive(PartialEq, Eq, Clone, Debug)] pub enum MockError { + /// An error occurred without any details. + NoDetails, + /// An I/O-Error occurred Io(io::ErrorKind), } @@ -16,6 +19,7 @@ impl From for MockError { impl fmt::Display for MockError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match self { + MockError::NoDetails => write!(f, "An error occurred without any details"), MockError::Io(kind) => write!(f, "I/O error: {:?}", kind), } } diff --git a/src/eh1/error.rs b/src/eh1/error.rs index c14d2f2..873c6a8 100644 --- a/src/eh1/error.rs +++ b/src/eh1/error.rs @@ -6,6 +6,9 @@ use embedded_hal::digital::ErrorKind::{self, Other}; /// Errors that may occur during mocking. #[derive(PartialEq, Eq, Clone, Debug)] pub enum MockError { + /// An error occurred without any details. + NoDetails, + /// An I/O-Error occurred Io(io::ErrorKind), } @@ -25,6 +28,7 @@ impl From for MockError { impl fmt::Display for MockError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match self { + MockError::NoDetails => write!(f, "An error occurred without any details"), MockError::Io(kind) => write!(f, "I/O error: {:?}", kind), } }