From 6a10e63ca0c79d9976a8d31daba064979736edd4 Mon Sep 17 00:00:00 2001 From: lukaramu Date: Sun, 19 Feb 2017 15:36:28 +0100 Subject: [PATCH 1/2] added Error and Display impl for std::ffi::FromBytesWithNulError --- src/libstd/ffi/c_str.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/libstd/ffi/c_str.rs b/src/libstd/ffi/c_str.rs index dc3855367ae27..2c18250b87eb0 100644 --- a/src/libstd/ffi/c_str.rs +++ b/src/libstd/ffi/c_str.rs @@ -455,6 +455,20 @@ impl From 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. From 48331ef8a16be02278802731fe8fb9f989b26a6a Mon Sep 17 00:00:00 2001 From: lukaramu Date: Tue, 21 Feb 2017 16:39:32 +0100 Subject: [PATCH 2/2] changed stability annotations Changed stability annotations for the new Error and Display impls for std::ffi::FromBytesWithNulError as they aren't subject to stability the same way. --- src/libstd/ffi/c_str.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libstd/ffi/c_str.rs b/src/libstd/ffi/c_str.rs index 2c18250b87eb0..bc678fcb8385b 100644 --- a/src/libstd/ffi/c_str.rs +++ b/src/libstd/ffi/c_str.rs @@ -455,14 +455,14 @@ impl From for io::Error { } } -#[unstable(feature = "frombyteswithnulerror_impls", reason = "recently added", issue = "39925")] +#[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" } } -#[unstable(feature = "frombyteswithnulerror_impls", reason = "recently added", issue = "39925")] +#[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)