Tracking Issue for strip_circumfix (original) (raw)
Feature gate: #![feature(strip_circumfix)]
This is a tracking issue for adding the strip_circumfix method to str and the slice primitives.
These methods are a shorter and more concise way to express these prevalent patterns that appear in a lot of code:
if let Some(a) = a.strip_prefix('<') && let Some(a) = a.strip_suffix('>') {}
// or...
let a = a.strip_prefix('<').and_then(|a| a.strip_suffix('>'));
Public API
impl str { pub fn strip_circumfix<P: Pattern, S: Pattern>(&self, prefix: P, suffix: S) -> Option<&str> where for<'a> S::Searcher<'a>: ReverseSearcher<'a>; }
impl [T] { pub fn strip_circumfix(&self, prefix: &P, suffix: &S) -> Option<&[T]> where P: SlicePattern<Item = T> + ?Sized, S: SlicePattern<Item = T> + ?Sized, T: PartialEq; }
Steps / History
(Remember to update the S-tracking-* label when checking boxes.)
- ACP: {str|slice}::strip_circumfix libs-team#680
- Implementation: Implement strip_circumfix lib feature #147947
- Final comment period (FCP)1
- Stabilization PR