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

This commit is contained in:
lukaramu 2017-02-19 15:36:28 +01:00
parent 0128be9ad7
commit 6a10e63ca0

View file

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