Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions src/decode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ use core::{self, fmt};

/// Possible decoding errors.
///
/// **Note**: The `std` feature is required for the `std::error::Error` impl and the conversion to
/// `std::io::Error`.
/// **Note**: The `std` feature is required for the conversion to `std::io::Error`.
#[non_exhaustive]
#[derive(Clone, Debug, PartialEq, Eq)]
pub enum Error {
Expand All @@ -46,9 +45,7 @@ impl fmt::Display for Error {
}
}

/// Only available when the feature `std` is present.
#[cfg(feature = "std")]
impl std::error::Error for Error {}
impl core::error::Error for Error {}

/// Only available when the feature `std` is present.
#[cfg(feature = "std")]
Expand Down
8 changes: 4 additions & 4 deletions src/io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,20 +59,20 @@ gen! {
#[derive(Debug)]
pub enum ReadError {
Io(io::Error),
Decode(decode::Error)
Decode(decode::Error),
}

impl fmt::Display for ReadError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match self {
ReadError::Io(e) => write!(f, "i/o error: {}", e),
ReadError::Decode(e) => write!(f, "decode error: {}", e)
ReadError::Decode(e) => write!(f, "decode error: {}", e),
}
}
}

impl std::error::Error for ReadError {
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
impl core::error::Error for ReadError {
fn source(&self) -> Option<&(dyn core::error::Error + 'static)> {
if let ReadError::Io(e) = self {
Some(e)
} else {
Expand Down