Feature gate: #![feature(substr_range)]
This is a tracking issue for str::substr_range, slice::subslice_range, and slice::element_offset as described in this ACP.
These methods can be used for error handling and to extend str::lines, str::split, slice::split, and other related methods.
Public API
impl str { fn substr_range(&self, substr: &str) -> Option<range::Range<usize>>; } impl<T> [T] { fn subslice_range(&self, subslice: &[T]) -> Option<range::Range<usize>>; // Already stabilized as `element_offset` fn element_offset(&self, element: &T) -> Option<usize>; }
Steps / History
- ACP
- Implementation: Add elem_offset and related methods #126770
- Rename
elem_offsettoelement_offset#132830 - Final comment period 1 (FCP)1
- Stabilization PR 1: Stabilize
slice::element_offset#150777 - Change to use the new
Rangetypes Makesubstr_rangeandsubslice_rangereturn the newRangetype #154707 - Final comment period 2 (FCP)1
- Stabilization PR 2: Stabilize
substr_rangeandsubslice_range#141266
Unresolved Questions
- Switch to the new
std::rangereturn types