remove deprecated from core::ffi::c_str

This commit is contained in:
Marijn Schouten 2025-07-02 12:26:20 +00:00
parent f51c9870ba
commit 674724c741

View file

@ -135,16 +135,20 @@ pub enum FromBytesWithNulError {
}
#[stable(feature = "frombyteswithnulerror_impls", since = "1.17.0")]
impl Error for FromBytesWithNulError {
#[allow(deprecated)]
fn description(&self) -> &str {
impl fmt::Display for FromBytesWithNulError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Self::InteriorNul { .. } => "data provided contains an interior nul byte",
Self::NotNulTerminated => "data provided is not nul terminated",
Self::InteriorNul { position } => {
write!(f, "data provided contains an interior nul byte at byte position {position}")
}
Self::NotNulTerminated => write!(f, "data provided is not nul terminated"),
}
}
}
#[stable(feature = "frombyteswithnulerror_impls", since = "1.17.0")]
impl Error for FromBytesWithNulError {}
/// An error indicating that no nul byte was present.
///
/// A slice used to create a [`CStr`] must contain a nul byte somewhere
@ -181,18 +185,6 @@ impl Default for &CStr {
}
}
#[stable(feature = "frombyteswithnulerror_impls", since = "1.17.0")]
impl fmt::Display for FromBytesWithNulError {
#[allow(deprecated, deprecated_in_future)]
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.write_str(self.description())?;
if let Self::InteriorNul { position } = self {
write!(f, " at byte pos {position}")?;
}
Ok(())
}
}
impl CStr {
/// Wraps a raw C string with a safe C string wrapper.
///