Skip to content
This repository was archived by the owner on Aug 15, 2025. It is now read-only.

Commit 6ddf412

Browse files
authored
fix: syntax issues causing compilation errors
1 parent 55fd029 commit 6ddf412

1 file changed

Lines changed: 12 additions & 13 deletions

File tree

src/error.rs

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//! Errors that can be encountering by Encoding and Decoding.
1+
//! Errors that can be encountered by encoding and decoding.
22
33
/// Errors that can be encountered by encoding a type
44
#[non_exhaustive]
@@ -35,7 +35,7 @@ pub enum EncodeError {
3535
index: usize,
3636
},
3737

38-
/// The encoder tried to encode a `Mutex` or `RwLock`, but the locking failed
38+
/// The encoder tried to encode a `Mutex` or RwLock`, but the locking failed
3939
#[cfg(feature = "std")]
4040
LockFailed {
4141
/// The type name of the mutex for debugging purposes
@@ -52,13 +52,12 @@ pub enum EncodeError {
5252
},
5353

5454
#[cfg(feature = "serde")]
55-
/// A serde-specific error that occurred while decoding.
55+
/// A serde-specific error that occurred while encoding.
5656
Serde(crate::features::serde::EncodeError),
5757
}
5858

5959
impl core::fmt::Display for EncodeError {
6060
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
61-
// TODO: Improve this?
6261
write!(f, "{:?}", self)
6362
}
6463
}
@@ -75,14 +74,6 @@ impl core::error::Error for EncodeError {
7574
}
7675
}
7776
}
78-
impl core::error::Error for DecodeError {
79-
fn source(&self) -> Option<&(dyn core::error::Error + 'static)> {
80-
match self {
81-
Self::Utf8 { inner } => Some(inner),
82-
_ => None,
83-
}
84-
}
85-
}
8677

8778
/// Errors that can be encountered by decoding a type
8879
#[non_exhaustive]
@@ -213,11 +204,19 @@ pub enum DecodeError {
213204

214205
impl core::fmt::Display for DecodeError {
215206
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
216-
// TODO: Improve this?
217207
write!(f, "{:?}", self)
218208
}
219209
}
220210

211+
impl core::error::Error for DecodeError {
212+
fn source(&self) -> Option<&(dyn core::error::Error + 'static)> {
213+
match self {
214+
Self::Utf8 { inner } => Some(inner),
215+
_ => None,
216+
}
217+
}
218+
}
219+
221220
impl DecodeError {
222221
/// If the current error is `InvalidIntegerType`, change the `expected` and
223222
/// `found` values from `Ux` to `Ix`. This is needed to have correct error

0 commit comments

Comments
 (0)