Skip to content

impl<T> SliceIndex<[T]> for (Bound<usize>, Bound<usize>) #49976

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
ExpHP opened this issue Apr 15, 2018 · 3 comments · Fixed by #77704
Closed

impl<T> SliceIndex<[T]> for (Bound<usize>, Bound<usize>) #49976

ExpHP opened this issue Apr 15, 2018 · 3 comments · Fixed by #77704
Labels
C-feature-request Category: A feature request, i.e: not implemented / a PR. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.

Comments

@ExpHP
Copy link
Contributor

ExpHP commented Apr 15, 2018

These feel like an omission to me, given how RangeArgument is implemented for this type:

impl<T> SliceIndex<[T]> for (Bound<usize>, Bound<usize>) { ... }
impl SliceIndex<str> for (Bound<usize>, Bound<usize>) { ... }

And if we really want to go for feature parity, then RangeArgument also has impls for (Bound<&T>, Bound<&T>), but I think that's mostly for the sake of methods like BTreeSet::range, and it really doesn't make sense here.
Edit: Then again, considering that RangeArgument is going to have methods that return Bound<&T>, maybe (Bound<&usize>, Bound<&usize>) is worth it.


(secretly, I just want the standard library to implement my bounds-checking and length-computation for me in my n-dimensional array, so that I can just write vec![(); len][(start_bound, end_bound)].len() and trust that it's correct. But shhhhhh, don't tell anyone)

@ExpHP
Copy link
Contributor Author

ExpHP commented Apr 15, 2018

On second thought, after seeing how meager libcore's test suite is for the existing indexing operations, I have decided that I should stop trusting the standard library and start contributing to it myself.

Working on a PR.


Edit: awww, looks like there's actually a good reason why there's no tests with vec![(); usize::MAX] or &[(); usize::MAX]. (the first takes forever on debug, the second sets forth The End of All Times)


Edit 2: How on earth does ..= not appear a single time in the tests for slice or str!?!

@Mark-Simulacrum Mark-Simulacrum added T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. C-feature-request Category: A feature request, i.e: not implemented / a PR. labels May 27, 2018
@AnthonyMikh
Copy link
Contributor

@ExpHP do you still have plans to make a PR for this feature?

@ExpHP
Copy link
Contributor Author

ExpHP commented Mar 26, 2020

Nope, totally forgot about this! Feel free to take the reins.

(looking back, it seems I went ahead with the test suite PR (#50010), but that took long enough to merge that by the time it was done I must have moved on to other things.)

Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this issue Apr 22, 2021
…und_pair, r=m-ou-se

Implement indexing slices with pairs of core::ops::Bound<usize>

Closes rust-lang#49976.

I am not sure about code duplication between `check_range` and `into_maybe_range`. Should be former implemented in terms of the latter? Also this PR doesn't address code duplication between `impl SliceIndex for Range*`.
Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this issue Apr 22, 2021
…und_pair, r=m-ou-se

Implement indexing slices with pairs of core::ops::Bound<usize>

Closes rust-lang#49976.

I am not sure about code duplication between `check_range` and `into_maybe_range`. Should be former implemented in terms of the latter? Also this PR doesn't address code duplication between `impl SliceIndex for Range*`.
Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this issue Apr 22, 2021
…und_pair, r=m-ou-se

Implement indexing slices with pairs of core::ops::Bound<usize>

Closes rust-lang#49976.

I am not sure about code duplication between `check_range` and `into_maybe_range`. Should be former implemented in terms of the latter? Also this PR doesn't address code duplication between `impl SliceIndex for Range*`.
Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this issue Apr 22, 2021
…und_pair, r=m-ou-se

Implement indexing slices with pairs of core::ops::Bound<usize>

Closes rust-lang#49976.

I am not sure about code duplication between `check_range` and `into_maybe_range`. Should be former implemented in terms of the latter? Also this PR doesn't address code duplication between `impl SliceIndex for Range*`.
@bors bors closed this as completed in ccf1712 Apr 22, 2021
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
C-feature-request Category: A feature request, i.e: not implemented / a PR. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants