-
Notifications
You must be signed in to change notification settings - Fork 13k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
added Error and Display impl for std::ffi::FromBytesWithNulError #39960
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shouldn't it be interior null byte? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not necessarily. https://en.wikipedia.org/wiki/Null_character Also note the name of the error type. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah I see, thanks for the correction @jmesmon |
||
} | ||
} | ||
|
||
#[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. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh unfortunately impls aren't subject to stability the same way as other parts of the standard library, so these'll be "insta-stable" so it's ok to just go ahead and tag this with
#[stable]