Rollup merge of #39960 - lukaramu:issue-39925, r=alexcrichton

added Error and Display impl for std::ffi::FromBytesWithNulError

Fixes #39925.

This is my first PR, so I wasn't quite sure about the stability annotation.
This commit is contained in:
Corey Farwell 2017-02-28 22:55:29 -05:00 committed by GitHub
commit 06a0233ab3
1 changed files with 14 additions and 0 deletions

View File

@ -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.