Rollup merge of #123661 - tgross35:stabilize-cstr_count_bytes, r=dtolnay

Stabilize `cstr_count_bytes`

Newly stable API:

```rust
impl CStr {
    pub fn count_bytes(&self) -> usize;
}
```

Const stabilization has not yet been decided, so that will continue to be gated under <https://github.com/rust-lang/rust/issues/113219>.

FCP finished at https://github.com/rust-lang/rust/issues/114441#issuecomment-2016942573.

Fixes: <https://github.com/rust-lang/rust/issues/114441>
This commit is contained in:
León Orell Valerian Liehr 2024-04-11 01:56:25 +02:00 committed by GitHub
commit d7d5be0c40
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 1 additions and 3 deletions

View File

@ -517,8 +517,6 @@ impl CStr {
/// # Examples
///
/// ```
/// #![feature(cstr_count_bytes)]
///
/// use std::ffi::CStr;
///
/// let cstr = CStr::from_bytes_with_nul(b"foo\0").unwrap();
@ -530,7 +528,7 @@ impl CStr {
#[inline]
#[must_use]
#[doc(alias("len", "strlen"))]
#[unstable(feature = "cstr_count_bytes", issue = "114441")]
#[stable(feature = "cstr_count_bytes", since = "CURRENT_RUSTC_VERSION")]
#[rustc_const_unstable(feature = "const_cstr_from_ptr", issue = "113219")]
pub const fn count_bytes(&self) -> usize {
self.inner.len() - 1