@@ -57,16 +57,12 @@ pub enum UnalignedCStr16Error {
57
57
58
58
impl Display for UnalignedCStr16Error {
59
59
fn fmt ( & self , f : & mut Formatter < ' _ > ) -> fmt:: Result {
60
- write ! (
61
- f,
62
- "{}" ,
63
- match self {
64
- Self :: InvalidChar ( _usize) => "invalid character" ,
65
- Self :: InteriorNul ( _usize) => "encountered null character" ,
66
- Self :: NotNulTerminated => "not null-terminated" ,
67
- Self :: BufferTooSmall => "buffer too small" ,
68
- }
69
- )
60
+ match self {
61
+ Self :: InvalidChar ( usize) => write ! ( f, "invalid character at index {}" , usize ) ,
62
+ Self :: InteriorNul ( usize) => write ! ( f, "interior null character at index {}" , usize ) ,
63
+ Self :: NotNulTerminated => write ! ( f, "not null-terminated" ) ,
64
+ Self :: BufferTooSmall => write ! ( f, "buffer too small" ) ,
65
+ }
70
66
}
71
67
}
72
68
@@ -89,15 +85,11 @@ pub enum FromStrWithBufError {
89
85
90
86
impl Display for FromStrWithBufError {
91
87
fn fmt ( & self , f : & mut Formatter < ' _ > ) -> fmt:: Result {
92
- write ! (
93
- f,
94
- "{}" ,
95
- match self {
96
- Self :: InvalidChar ( _usize) => "invalid character" ,
97
- Self :: InteriorNul ( _usize) => "encountered null character" ,
98
- Self :: BufferTooSmall => "buffer too small" ,
99
- }
100
- )
88
+ match self {
89
+ Self :: InvalidChar ( usize) => write ! ( f, "invalid character at index {}" , usize ) ,
90
+ Self :: InteriorNul ( usize) => write ! ( f, "interior null character at index {}" , usize ) ,
91
+ Self :: BufferTooSmall => write ! ( f, "buffer too small" ) ,
92
+ }
101
93
}
102
94
}
103
95
0 commit comments