Skip to content

Tracking Issue for const_cstr_from_ptr #113219

Closed

Description

@tgross35

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

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.

Activity

  1. added
    C-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFC
    T-libs-api[DEPRECATED; DO NOT USE]
    on Jul 1, 2023
  2. added 3 commits that reference this issue on Jul 22, 2023
  3. tgross35 commented on Aug 3, 2023

    @tgross35
    MemberAuthor

    I gated CStr::count_bytes()'s constness under this same flag since it depends on the same decision. See #114443

  4. 28 remaining items

  5. added and removed
    final-comment-periodIn the final comment period and will be merged soon unless new substantive objections are raised.
    on Jul 6, 2024
  6. rfcbot commented on Jul 6, 2024

    @rfcbot

    The final comment period, with a disposition to merge, as per the review above, is now complete.

    As the automated representative of the governance process, I would like to thank the author for their work and everyone else who contributed.

    This will be merged soon.

  7. added a commit that references this issue on Jul 12, 2024
  8. added a commit that references this issue on Jul 12, 2024
  9. added 3 commits that reference this issue on Jul 12, 2024
  10. added a commit that references this issue on Jul 12, 2024
  11. added a commit that references this issue on Jul 12, 2024
  12. added a commit that references this issue on Jul 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFCT-langRelevant to the language teamT-libs-api[DEPRECATED; DO NOT USE]disposition-mergeThis issue / PR is in PFCP or FCP with a disposition to merge it.finished-final-comment-periodThe final comment period is finished for this PR / Issue.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions