Skip to content

Commit 3792317

Browse files
authored
derive standard traits for Errors (#67)
* Copy only of not custom-error-messages * Also fix the custom-error-messages feature to use const generics String
1 parent bbe26b2 commit 3792317

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

src/de/mod.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ mod seq;
1717
pub type Result<T> = core::result::Result<T, Error>;
1818

1919
/// This type represents all possible errors that can occur when deserializing JSON data
20-
#[derive(Debug, PartialEq)]
20+
#[derive(Debug, PartialEq, Eq, Clone)]
21+
#[cfg_attr(not(feature = "custom-error-messages"), derive(Copy))]
2122
#[non_exhaustive]
2223
pub enum Error {
2324
/// EOF while parsing a list.
@@ -73,7 +74,7 @@ pub enum Error {
7374

7475
/// Error with a custom message that was preserved.
7576
#[cfg(feature = "custom-error-messages")]
76-
CustomErrorWithMessage(heapless::String<heapless::consts::U64>),
77+
CustomErrorWithMessage(heapless::String<64>),
7778
}
7879

7980
#[cfg(feature = "std")]

src/ser/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ mod struct_;
2020
pub type Result<T> = ::core::result::Result<T, Error>;
2121

2222
/// This type represents all possible errors that can occur when serializing JSON data
23-
#[derive(Debug)]
23+
#[derive(Debug, PartialEq, Eq, Copy, Clone)]
2424
#[non_exhaustive]
2525
pub enum Error {
2626
/// Buffer is full

0 commit comments

Comments
 (0)