Open
Description
The feature gate for the issue is #![feature(slice_range)]
.
This issue currently tracks the following API:
pub mod slice {
pub fn range<R>(range: R, bounds: RangeTo<usize>) -> Range<usize>
where
R: RangeBounds<usize>;
}
About tracking issues
Tracking issues are used to record the overall progress of implementation.
They are also used as hubs connecting to other relevant issues, e.g., bugs or open design questions.
A tracking issue is however not meant for large scale discussion, questions, or bug reports about a feature.
Instead, open a dedicated issue for the specific matter and add the relevant feature gate label.
Steps
- Implement the feature (Add
slice::check_range
#75207) - Adjust documentation (Adjust documentation for slice_check_range #76395)
- Stabilization PR (see instructions on rustc-dev-guide)
Unresolved Questions
Should this method be defined on(MoveRangeBounds
orRange
instead?slice::check_range
toRangeBounds
#76885)Should a non-panicking version be added?- Should this wait for
#[final]
methods in traits?- The main reason this isn't on
RangeBounds
is that todayunsafe
code can't trust any method on a not-unsafe trait to validate anything. But if this was a final method, and thus not overridable, thenunsafe
code could trust it.
- The main reason this isn't on
Implementation history
- Implemented in Add
slice::check_range
#75207 - Adjust documentation for slice_check_range #76395
- Changed type (taking only the length) in Fix liballoc test suite for Miri #76662
- Move
slice::check_range
toRangeBounds
#76885 - Renamed to
slice::range
in Improve design ofassert_len
#81154 - add #[must_use] to functions of slice and its iterators. #95274
- Add slice::try_range #121148