Skip to content

Commit f37f469

Browse files
authored
Merge pull request #610 from raccog/error-displays
Implement `Error` and `Display` traits for `FromStrError`
2 parents 5c972c7 + 51602d1 commit f37f469

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

uefi/src/data_types/owned_strs.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,22 @@ pub enum FromStrError {
1515
InteriorNul,
1616
}
1717

18+
impl fmt::Display for FromStrError {
19+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
20+
write!(
21+
f,
22+
"UCS-2 Conversion Error: {}",
23+
match self {
24+
Self::InvalidChar => "Invalid character",
25+
Self::InteriorNul => "Interior null terminator",
26+
}
27+
)
28+
}
29+
}
30+
31+
#[cfg(feature = "unstable")]
32+
impl core::error::Error for FromStrError {}
33+
1834
/// An owned UCS-2 null-terminated string.
1935
///
2036
/// For convenience, a [CString16] is comparable with `&str` and `String` from the standard library

0 commit comments

Comments
 (0)