-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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 2295, "Extend Pattern API to OsStr" #49802
Comments
Status update: I've got the implementation of this ready, but I'd like to wait for a decision on rust-lang/rfcs#2500 first, as I believe this isn't an urgent feature. Without the pattern API part, this RFC will only provide the slicing operation ( |
Now that rust-lang/rfcs#2500 has merged, can this RFC be implemented? |
@rustbot claim |
@rustbot unassign |
Hey @rust-lang/libs-api team, since it was decided to revert the Needle/Pattern API stabilization, what is the status of this? I hope it won't be reverted, too. It would still really help me with cross-platform compatibility. |
@jhwgh1968 We're not planning on reverting impls of this trait; we're keeping the trait. We're just planning to seal it and not support implementations outside the standard library. |
@rustbot claim |
Is like to try my hand at implementing this. I've read the RFC and the OMG-WTF-8 spec, but I want to make sure I understand the reason for OMG-WTF-8. My understanding is that Windows does not require that various strings are actually valid UTF-16. Any @kennytm you mention having an implementation ready. Is that just the omgwtf8 package, or did you have a rust branch set up? If the latter, please share. Thanks! |
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
Pattern is no longer str-specific, so move it from core::str::pattern module to a new core::pattern module. This introduces no changes in behaviour or implementation. Just moves stuff around and adjusts documentation. Issue: rust-lang#49802
Negative delta FTW. Issue: rust-lang#49802
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
@pitaj, FYI I’ve actually started looking into this myself. You can see stuff I’ve done so far at master...mina86:rust:wtf For now this is just Pattern API stuff and not even exactly conforming to this RFC (see my comment under the RFC PR) (plus some I’ve just started looking at OsStr. To answer your question, yes, pretty much. |
@mina86 cool! Are you on zulip? Are you open to collaborating on the implementation? It's my understanding that |
You may be right about Haystack now that I read the RFC again. I’ll ping you on Zulip then. |
This is a tracking issue for the RFC "Extend Pattern API to OsStr" (rust-lang/rfcs#2295).
Steps:
Unresolved questions:
None
The text was updated successfully, but these errors were encountered: