Closed
Description
Feature gate: #![feature(const_cstr_from_ptr)]
This is a tracking issue for using CStr::from_ptr()
in a const context.
This method was previously gated under const_cstr_methods
, but was split off after discussion in #107624 (review).
Public API
// core/ffi/c_str.rs
impl CStr {
pub const unsafe fn from_ptr<'a>(ptr: *const c_char) -> &'a CStr;
pub const fn count_bytes(&self) -> usize;
}
Steps / History
- Implementation
-
Blocked on Relax const-eval restrictions rfcs#3352 (?)- Not blocked after all
- Final comment period (FCP)[^1]
- Stabilization PR: Stabilize const_cstr_from_ptr (CStr::from_ptr, CStr::count_bytes) #127433
Unresolved Questions
Making this const currently depends on const_eval_select
, which unstable. If const_eval_select
becomes internally usable, we will be able to stabilize this.
The other currently available option is to always use a const strlen
, but this would come with a performance hit.
Alternatively, whenever CStr
becomes a thin pointer this can be const stabilized since it will have no internal operations.
Metadata
Metadata
Assignees
Labels
Category: An issue tracking the progress of sth. like the implementation of an RFCRelevant to the language team, which will review and decide on the PR/issue.Relevant to the library API team, which will review and decide on the PR/issue.This issue / PR is in PFCP or FCP with a disposition to merge it.The final comment period is finished for this PR / Issue.