We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 4eaf45f commit 5ebf95dCopy full SHA for 5ebf95d
src/writer.rs
@@ -8,12 +8,14 @@ use alloc::{fmt, vec};
8
#[derive(PartialEq, Eq, Debug)]
9
pub enum WriteError {
10
AllocationError,
11
+ CustomError(String),
12
}
13
14
impl fmt::Display for WriteError {
15
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
16
match self {
17
WriteError::AllocationError => write!(f, "allocation error"),
18
+ WriteError::CustomError(s) => write!(f, "{s}"),
19
20
21
@@ -788,5 +790,9 @@ mod tests {
788
790
fn test_write_error_display() {
789
791
use alloc::string::ToString;
792
assert_eq!(&WriteError::AllocationError.to_string(), "allocation error");
793
+ assert_eq!(
794
+ &WriteError::CustomError("my error".to_string()).to_string(),
795
+ "my error"
796
+ );
797
798
0 commit comments