Content-Length: 314725 | pFad | https://github.com/celinval/rust-dev/commit/bcdc8e8471de7cebbb9e24b347feb1609fa71698

9C Stabilize const_cstr_from_ptr (CStr::from_ptr, CStr::count_bytes) · celinval/rust-dev@bcdc8e8 · GitHub
Skip to content

Commit bcdc8e8

Browse files
committed
Stabilize const_cstr_from_ptr (CStr::from_ptr, CStr::count_bytes)
1 parent 5569ece commit bcdc8e8

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

core/src/ffi/c_str.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -263,8 +263,6 @@ impl CStr {
263263
//github.com/ ```
264264
//github.com/
265265
//github.com/ ```
266-
//github.com/ #![feature(const_cstr_from_ptr)]
267-
//github.com/
268266
//github.com/ use std::ffi::{c_char, CStr};
269267
//github.com/
270268
//github.com/ const HELLO_PTR: *const c_char = {
@@ -280,7 +278,7 @@ impl CStr {
280278
#[inline] // inline is necessary for codegen to see strlen.
281279
#[must_use]
282280
#[stable(feature = "rust1", since = "1.0.0")]
283-
#[rustc_const_unstable(feature = "const_cstr_from_ptr", issue = "113219")]
281+
#[rustc_const_stable(feature = "const_cstr_from_ptr", since = "CURRENT_RUSTC_VERSION")]
284282
pub const unsafe fn from_ptr<'a>(ptr: *const c_char) -> &'a CStr {
285283
// SAFETY: The caller has provided a pointer that points to a valid C
286284
// string with a NUL terminator less than `isize::MAX` from `ptr`.
@@ -542,7 +540,7 @@ impl CStr {
542540
#[must_use]
543541
#[doc(alias("len", "strlen"))]
544542
#[stable(feature = "cstr_count_bytes", since = "1.79.0")]
545-
#[rustc_const_unstable(feature = "const_cstr_from_ptr", issue = "113219")]
543+
#[rustc_const_stable(feature = "const_cstr_from_ptr", since = "CURRENT_RUSTC_VERSION")]
546544
pub const fn count_bytes(&self) -> usize {
547545
self.inner.len() - 1
548546
}
@@ -742,6 +740,8 @@ impl AsRef<CStr> for CStr {
742740
//github.com/ The pointer must point to a valid buffer that contains a NUL terminator. The NUL must be
743741
//github.com/ located within `isize::MAX` from `ptr`.
744742
#[inline]
743+
#[rustc_const_stable(feature = "const_cstr_from_ptr", since = "CURRENT_RUSTC_VERSION")]
744+
#[rustc_allow_const_fn_unstable(const_eval_select)]
745745
const unsafe fn const_strlen(ptr: *const c_char) -> usize {
746746
const fn strlen_ct(s: *const c_char) -> usize {
747747
let mut len = 0;

0 commit comments

Comments
 (0)








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: https://github.com/celinval/rust-dev/commit/bcdc8e8471de7cebbb9e24b347feb1609fa71698

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy