diff options
| author | Corey Farwell <coreyf@rwell.org> | 2017-02-28 22:55:29 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-02-28 22:55:29 -0500 |
| commit | 06a0233ab315c68e45dce27e0fdb74ff340b2fd9 (patch) | |
| tree | ec9bc738de39b087b6871a7058fca2dfc4d32007 /src | |
| parent | fda3f9874627fee7a8d3605c76b441d4c9b2540f (diff) | |
| parent | 48331ef8a16be02278802731fe8fb9f989b26a6a (diff) | |
| download | rust-06a0233ab315c68e45dce27e0fdb74ff340b2fd9.tar.gz rust-06a0233ab315c68e45dce27e0fdb74ff340b2fd9.zip | |
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.
Diffstat (limited to 'src')
| -rw-r--r-- | src/libstd/ffi/c_str.rs | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/libstd/ffi/c_str.rs b/src/libstd/ffi/c_str.rs index dc3855367ae..bc678fcb838 100644 --- a/src/libstd/ffi/c_str.rs +++ b/src/libstd/ffi/c_str.rs @@ -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. |
