Skip to content

Commit

Permalink
added Error and Display impl for std::ffi::FromBytesWithNulError
Browse files Browse the repository at this point in the history
  • Loading branch information
chordowl committed Feb 19, 2017
1 parent 0128be9 commit 6a10e63
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 {
}
}

#[unstable(feature = "frombyteswithnulerror_impls", reason = "recently added", issue = "39925")]
impl Error for FromBytesWithNulError {
fn description(&self) -> &str {
"data provided is not null terminated or contains an interior nul byte"
}
}

#[unstable(feature = "frombyteswithnulerror_impls", reason = "recently added", issue = "39925")]
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 6a10e63

Please sign in to comment.