Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement source instead of cause on std::error::Error types #243

Merged
merged 1 commit into from
Aug 26, 2023
Merged
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
8 changes: 2 additions & 6 deletions src/decode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,7 @@ impl fmt::Display for DecodeError {
}

#[cfg(any(feature = "std", test))]
impl error::Error for DecodeError {
fn cause(&self) -> Option<&dyn error::Error> {
None
}
}
impl error::Error for DecodeError {}

/// Errors that can occur while decoding into a slice.
#[derive(Clone, Debug, PartialEq, Eq)]
Expand All @@ -69,7 +65,7 @@ impl fmt::Display for DecodeSliceError {

#[cfg(any(feature = "std", test))]
impl error::Error for DecodeSliceError {
fn cause(&self) -> Option<&dyn error::Error> {
fn source(&self) -> Option<&(dyn error::Error + 'static)> {
match self {
DecodeSliceError::DecodeError(e) => Some(e),
DecodeSliceError::OutputSliceTooSmall => None,
Expand Down
6 changes: 1 addition & 5 deletions src/encode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,11 +149,7 @@ impl fmt::Display for EncodeSliceError {
}

#[cfg(any(feature = "std", test))]
impl error::Error for EncodeSliceError {
fn cause(&self) -> Option<&dyn error::Error> {
None
}
}
impl error::Error for EncodeSliceError {}

#[cfg(test)]
mod tests {
Expand Down