Skip to content

Commit

Permalink
Rollup merge of rust-lang#39960 - lukaramu:issue-39925, r=alexcrichton
Browse files Browse the repository at this point in the history
added Error and Display impl for std::ffi::FromBytesWithNulError

Fixes rust-lang#39925.

This is my first PR, so I wasn't quite sure about the stability annotation.
  • Loading branch information
frewsxcv committed Mar 1, 2017
2 parents fda3f98 + 48331ef commit 06a0233
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/libstd/ffi/c_str.rs
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,20 @@ impl From<NulError> for io::Error {
}
}

#[stable(feature = "frombyteswithnulerror_impls", since = "1.17.0")]
impl Error for FromBytesWithNulError {
fn description(&self) -> &str {
"data provided is not null terminated or contains an interior nul byte"
}
}

#[stable(feature = "frombyteswithnulerror_impls", since = "1.17.0")]
impl fmt::Display for FromBytesWithNulError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
self.description().fmt(f)
}
}

impl IntoStringError {
/// Consumes this error, returning original `CString` which generated the
/// error.
Expand Down

0 comments on commit 06a0233

Please sign in to comment.