rust-lang / rust-lang/rust

Tracking Issue for `str::first_char`, `str::split_first_char` et al.

Open
#154,393 2 comments 0 reactions 1 assignee View on GitHub

@F0RREALTHO is already working on this.

Since Mar 29, 2026.

C-tracking-issue S-tracking-unimplemented T-libs
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

Feature gate: #![feature(str_first_last_char)]

This is a tracking issue for methods for extracting the first or last character of a str as a char. PR #89603 was submitted in 2021 (predating ACPs) but was closed after a few months due to author inactivity. ACP rust-lang/libs-team#764 proposes trying again to add these methods, this time constified.

Public API
// core::str

impl str {
    pub const fn first_char(&self) -> Option<char>
    pub const fn last_char(&self) -> Option<char>
    pub const fn split_first_char(&self) -> Option<(char, &str)>
    pub const fn split_last_char(&self) -> Option<(char, &str)>
}
Steps / History

(Remember to update the S-tracking-* label when checking boxes.)

  • ACP: rust-lang/libs-team#764
  • Implementation: #89603 (abandoned, not const)
  • Final comment period (FCP)^1
  • Stabilization PR
Unresolved Questions
  • _char suffix or not?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.