Tracking Issue for `slice_split_once`

Feature gate: #![feature(slice_split_once)]

This is a tracking issue for the slice::split_once and slice::rsplit_once methods, which split a slice into two chunks on the first occurrence of a single-element delimiter. These mirror the existing stable str::split_once and str::rsplit_once. I expect these to be mostly used for ad-hoc parsing data that is not UTF-8.

Public API

// core::slice

impl [T] {
    pub fn split_once<F>(&self, pred: F) -> Option<(&[T], &[T])>
    where
        F: FnMut(&T) -> bool;
    pub fn rsplit_once<F>(&self, pred: F) -> Option<(&[T], &[T])>
    where
        F: FnMut(&T) -> bool;
}

Steps / History

Unresolved Questions

  • Should we include split_once_mut and rsplit_once_mut?
  1. https://std-dev-guide.rust-lang.org/feature-lifecycle/stabilization.html