Skip to content

Commit 6a10e63

Browse files
committed
added Error and Display impl for std::ffi::FromBytesWithNulError
1 parent 0128be9 commit 6a10e63

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/libstd/ffi/c_str.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -455,6 +455,20 @@ impl From<NulError> for io::Error {
455455
}
456456
}
457457

458+
#[unstable(feature = "frombyteswithnulerror_impls", reason = "recently added", issue = "39925")]
459+
impl Error for FromBytesWithNulError {
460+
fn description(&self) -> &str {
461+
"data provided is not null terminated or contains an interior nul byte"
462+
}
463+
}
464+
465+
#[unstable(feature = "frombyteswithnulerror_impls", reason = "recently added", issue = "39925")]
466+
impl fmt::Display for FromBytesWithNulError {
467+
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
468+
self.description().fmt(f)
469+
}
470+
}
471+
458472
impl IntoStringError {
459473
/// Consumes this error, returning original `CString` which generated the
460474
/// error.

0 commit comments

Comments
 (0)