diff options
| author | bors <bors@rust-lang.org> | 2020-09-04 12:21:43 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2020-09-04 12:21:43 +0000 |
| commit | ef55a0a92f3cb6572ef67d99f4aefbdeb7b6b804 (patch) | |
| tree | f811be6020731d8ff158e0e4d6b0265c9662370d /compiler/rustc_mir/src/monomorphize/collector.rs | |
| parent | 4ffb5c5954a304daf47a567b34e74e421db86d98 (diff) | |
| parent | d9e877fb98212a47dd425e145b8b3e4283e6b487 (diff) | |
| download | rust-ef55a0a92f3cb6572ef67d99f4aefbdeb7b6b804.tar.gz rust-ef55a0a92f3cb6572ef67d99f4aefbdeb7b6b804.zip | |
Auto merge of #75207 - dylni:add-slice-check-range, r=KodrAus
Add `slice::check_range` This method is useful for [`RangeBounds`] parameters. It's even been [rewritten](https://github.com/rust-lang/rust/blob/22ee68dc586440f96b76b32fbd6087507c6afdb9/src/librustc_data_structures/sorted_map.rs#L214) [many](https://github.com/rust-lang/rust/blob/22ee68dc586440f96b76b32fbd6087507c6afdb9/library/alloc/src/vec.rs#L1299) [times](https://github.com/rust-lang/rust/blob/22ee68dc586440f96b76b32fbd6087507c6afdb9/library/core/src/slice/mod.rs#L2441) in the standard library, sometimes assuming that the bounds won't be [`usize::MAX`]. For example, [`Vec::drain`] creates an empty iterator when [`usize::MAX`] is used as an inclusive end bound: ```rust assert!(vec![1].drain(..=usize::max_value()).eq(iter::empty())); ``` If this PR is merged, I'll create another to use it for those methods. [`RangeBounds`]: https://doc.rust-lang.org/std/ops/trait.RangeBounds.html [`usize::MAX`]: https://doc.rust-lang.org/std/primitive.usize.html#associatedconstant.MAX [`Vec::drain`]: https://doc.rust-lang.org/std/vec/struct.Vec.html#method.drain
Diffstat (limited to 'compiler/rustc_mir/src/monomorphize/collector.rs')
0 files changed, 0 insertions, 0 deletions
