-
Notifications
You must be signed in to change notification settings - Fork 12.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Tracking issue for RFC 2500, "Needle API (née Pattern API)" #56345
Comments
(Added a mention to RFC 1672 as promised) |
Will |
Does it matter? This method only takes |
Changing the internal implementation does appear to be API compatible. |
I think this is subtle enough to be worth a dedicated API. Even if it was as simple as |
[WIP] Implement Needle API (RFC 2500) cc #56345 ---- Insta-stable changes: * `impl Index<Range***> for OsStr` cannot be gated and is insta-stable. I'll add more comments after the crater run.
[WIP] Implement Needle API (RFC 2500) cc #56345 ---- Insta-stable changes: * `impl Index<Range***> for OsStr` cannot be gated and is insta-stable. I'll add more comments after the crater run.
[WIP] Implement Needle API (RFC 2500) cc #56345 ---- Insta-stable changes: * `impl Index<Range***> for OsStr` cannot be gated and is insta-stable. I'll add more comments after the crater run.
Any news on |
…=kennytm Optimize strip_prefix and strip_suffix with str patterns As mentioned in rust-lang#67302 (comment). I'm not sure whether adding these methods to `Pattern` is desirable—but they have default implementations so the change is backwards compatible. Plus it seems like they're slated for wholesale replacement soon anyway? rust-lang#56345 ---- Constructing a Searcher in strip_prefix and strip_suffix is unnecessarily slow when the pattern is a fixed-length string. Add strip_prefix and strip_suffix methods to the Pattern trait, and add optimized implementations of these methods in the str implementation. The old implementation is retained as the default for these methods.
…=kennytm Optimize strip_prefix and strip_suffix with str patterns As mentioned in rust-lang#67302 (comment). I'm not sure whether adding these methods to `Pattern` is desirable—but they have default implementations so the change is backwards compatible. Plus it seems like they're slated for wholesale replacement soon anyway? rust-lang#56345 ---- Constructing a Searcher in strip_prefix and strip_suffix is unnecessarily slow when the pattern is a fixed-length string. Add strip_prefix and strip_suffix methods to the Pattern trait, and add optimized implementations of these methods in the str implementation. The old implementation is retained as the default for these methods.
…=kennytm Optimize strip_prefix and strip_suffix with str patterns As mentioned in rust-lang#67302 (comment). I'm not sure whether adding these methods to `Pattern` is desirable—but they have default implementations so the change is backwards compatible. Plus it seems like they're slated for wholesale replacement soon anyway? rust-lang#56345 ---- Constructing a Searcher in strip_prefix and strip_suffix is unnecessarily slow when the pattern is a fixed-length string. Add strip_prefix and strip_suffix methods to the Pattern trait, and add optimized implementations of these methods in the str implementation. The old implementation is retained as the default for these methods.
According to #76901 (comment) and corresponding t-libs fcp, this rfc is withdrawn. Closing. |
Implement Haystack<&[T]> and corresponding Pattern<&[T]> for &[T]. That is, provide implementation for searching for subslices in slices. This replaces SlicePattern type. To make use of this new implementations, provide a few new methods on [T] type modelling them after types on str. Specifically, introduce {starts,ends}_with_pattern, find, rfind, [T]::{split,rsplit}_once and trim{,_start,_end}_matches. Note that due to existing starts_with and ends_with methods, the _pattern suffix had to be used. This is unfortunate but the type of starts_with’s argument cannot be changed without affecting type inference and thus breaking the API. This change doesn’t implement functions returning iterators such as split_pattern or matches which in str type are built on top of the Pattern API. Issue: rust-lang#49802 Issue: rust-lang#56345
This is a tracking issue for the RFC "Needle API (née Pattern API)" (rust-lang/rfcs#2500).
Feature gates:
#![feature(needle)]
(the traits and method incore::needle
itself, and impl of these traits)#![feature(str_find_range)]
(find_range
,rfind_range
,match_ranges
andrmatch_ranges
methods forstr
)#![feature(mut_str_needle_methods)]
(split_mut
,matches_mut
,trim_mut
etc forstr
)#![feature(slice_needle_methods)]
(find
,matches
,trim_matches
,replace
,split
etc for[T]
)#![feature(os_str_needle_methods)]
(find
,matches
etc forOsStr
)Steps:
Unresolved questions:
Currently, due to Implied bounds rfcs#2089 and/or RFC: Associated type bounds of form
MyTrait<AssociatedType: Bounds>
rfcs#2289 not being implemented, using aHaystack
in any algorithm would need to a redundantwhere
clause.Naive vs. fast algorithm for
T: !Ord
Should we represent
SharedHaystack
using a more general concept of "cheaply cloneable"?With a benefit of simplified API, do we want to merge
Consumer
andSearcher
into a single trait?Stabilization should require RFC 1672 (disjointness based on associated types).
The text was updated successfully, but these errors were encountered: