-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Add range_of
to slice/str return a Range
, opposite to get
#96612
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
Conversation
Hey! It looks like you've submitted a new PR for the library teams! If this PR contains changes to any Examples of
|
r? @m-ou-se (rust-highfive has picked a reviewer for you, use r? to override) |
I guess |
This comment has been minimized.
This comment has been minimized.
See also RFC 2796 (still open). @SimonSapin's implementation there has a different (non-panicking) approach to ZSTs and handles some |
Well, looks like I was a bit overeager with this PR, as I didn’t know there was already an effort towards this goal (though they don’t seem to have much traction either). Either way, I rebased this, handled the ZST case by only guaranteeing slice-to-slice roundtrips (though that might need explicit tests?) and changed to impl to be based on |
This comment has been minimized.
This comment has been minimized.
Hey! It looks like you've submitted a new PR for the library teams! If this PR contains changes to any Examples of
|
The job Click to see the possible cause of the failure (guessed by this bot)
|
Returns the range of the sub-slice/str within
self
. The resultingRange
can be used withget
to yield the exact same slice again, completing a roundtrip.I proposed this in https://internals.rust-lang.org/t/proposal-get-range-of-sub-slice/16556 and might as well open a PR ;-)
Tracking issue coming soon.