Remove FromBytesWithNulErrorKind and make FromVecWithNulErrorKind more actionable by PixelDust22 · Pull Request #143163 · rust-lang/rust (original) (raw)

#134143 converted FromBytesWithNulError into an enum to address rust-lang/libs-team#493 (CStr::from_bytes_with_nul returns non-actionable error result)

However, the FromVecWithNulError returned from CString::from_vec_with_nul has a similar issue of returning non-actionable error result because you can't get the FromBytesWithNulErrorKind out of FromVecWithNulError.

Additionally, #134143 creates FromBytesWithNulError alongside the existing FromBytesWithNulErrorKind which is exactly the same.

This PR removes FromBytesWithNulErrorKind so that FromVecWithNulError uses FromBytesWithNulError directly. It also adds a new method kind to FromVecWithNulError so that the user can access the underlying error.

This is not a breaking change because FromBytesWithNulErrorKind is private, and we're only adding a method to FromVecWithNulError.

cc @nyurik