Add slice::check_range by dylni · Pull Request #75207 · rust-lang/rust (original) (raw)

There are 3 more ad-hoc implementations:

The bounds aren't integers, and they're not used for a slice.

| let end = match end { |
| Bound::Included(hi) => hi + 1, |
| Bound::Excluded(hi) => hi, |
| Bound::Unbounded => length, |
| }; |

I don't think this method is allowed to panic, but it also doesn't use a slice.

| let end = match range.end_bound() { |
| Bound::Included(ref k) => match self.lookup_index_for(k) { |
| Ok(index) => index + 1, |
| Err(index) => index, |
| }, |
| Bound::Excluded(ref k) => match self.lookup_index_for(k) { |
| Ok(index) | Err(index) => index, |
| }, |
| Bound::Unbounded => self.data.len(), |
| }; |

I don't see any way check_range could be defined that would help here.