Skip to content

Commit 49e27f1

Browse files
committed
Implement error::Error and fmt::Display for string::ParseError
Fixes #31106.
1 parent e1cb0a3 commit 49e27f1

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

src/libcollections/string.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1692,6 +1692,13 @@ impl fmt::Debug for ParseError {
16921692
}
16931693
}
16941694

1695+
#[stable(feature = "str_parse_error2", since = "1.8.0")]
1696+
impl fmt::Display for ParseError {
1697+
fn fmt(&self, _: &mut fmt::Formatter) -> fmt::Result {
1698+
match *self {}
1699+
}
1700+
}
1701+
16951702
#[stable(feature = "str_parse_error", since = "1.5.0")]
16961703
impl PartialEq for ParseError {
16971704
fn eq(&self, _: &ParseError) -> bool {

src/libstd/error.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,13 @@ impl Error for string::FromUtf16Error {
182182
}
183183
}
184184

185+
#[stable(feature = "str_parse_error2", since = "1.8.0")]
186+
impl Error for string::ParseError {
187+
fn description(&self) -> &str {
188+
"parse error"
189+
}
190+
}
191+
185192
// copied from any.rs
186193
impl Error + 'static {
187194
/// Returns true if the boxed type is the same as `T`

0 commit comments

Comments
 (0)