forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
core: convert Pattern<'a> into Pattern<H: Haystack> (RFC 2295)
As per RFC 2295, add a Haystack trait describing something that can be searched in and make core::str::Pattern (and related types) generic on that trait. This will allow Pattern to be used for types other than str (most notably OsStr). The change mostly follows the RFC though there are some differences in Haystack trait. Most notably, instead of separate StartCursor and EndCursors types, there’s one Cursor type instead. This eliminate the need for methods converting between the two types of cursors. Conversion from cursor to offset isn’t included either since as far as I can tell it’s not needed. A generic code operating on Haystack doesn’t need a concept of offset. It can operate on cursors instead. Lastly, rather than range_to_self as suggested in RFC this commit implements split_at_cursor_unchecked which simplifies default implementation of strip_prefix_of and strip_suffix_of. For now leave Pattern, Haystack et al in core::str::pattern. Since they are no longer str-specific, I’ll move them to core::pattern in future commit. This one leaves them in place to make the diff smaller. Issue: rust-lang#49802
- Loading branch information
Showing
11 changed files
with
229 additions
and
182 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.