Skip to content

Commit 7715888

Browse files
committed
additional cleanup of Display impls
1 parent 95e801a commit 7715888

File tree

2 files changed

+14
-26
lines changed

2 files changed

+14
-26
lines changed

uefi/src/data_types/strs.rs

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -57,16 +57,12 @@ pub enum UnalignedCStr16Error {
5757

5858
impl Display for UnalignedCStr16Error {
5959
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+
}
7066
}
7167
}
7268

@@ -89,15 +85,11 @@ pub enum FromStrWithBufError {
8985

9086
impl Display for FromStrWithBufError {
9187
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+
}
10193
}
10294
}
10395

uefi/src/proto/driver/component_name.rs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -240,13 +240,9 @@ pub enum LanguageError {
240240

241241
impl Display for LanguageError {
242242
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
243-
write!(
244-
f,
245-
"{}",
246-
match self {
247-
Self::Ascii { index } => "invalid character at index: {index}",
248-
}
249-
)
243+
match self {
244+
Self::Ascii { index } => write!(f, "invalid character at index: {index}"),
245+
}
250246
}
251247
}
252248

0 commit comments

Comments
 (0)