Rollup merge of #123271 - JaniM:janim/sliceindex-doc, r=Nilstrieb
doc: describe panic conditions for SliceIndex implementations Implementation note: The most probable place for users to find the documentation is at https://doc.rust-lang.org/std/slice/trait.SliceIndex.html On that page, documentation added to specific methods will not be visible. As such, I opted to add the comments to the impl blocks directly. Helps with #121568.
This commit is contained in:
commit
42ca32673a
@ -195,6 +195,7 @@ pub unsafe trait SliceIndex<T: ?Sized>: private_slice_index::Sealed {
|
|||||||
fn index_mut(self, slice: &mut T) -> &mut Self::Output;
|
fn index_mut(self, slice: &mut T) -> &mut Self::Output;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// The methods `index` and `index_mut` panic if the index is out of bounds.
|
||||||
#[stable(feature = "slice_get_slice_impls", since = "1.15.0")]
|
#[stable(feature = "slice_get_slice_impls", since = "1.15.0")]
|
||||||
#[rustc_const_unstable(feature = "const_slice_index", issue = "none")]
|
#[rustc_const_unstable(feature = "const_slice_index", issue = "none")]
|
||||||
unsafe impl<T> SliceIndex<[T]> for usize {
|
unsafe impl<T> SliceIndex<[T]> for usize {
|
||||||
@ -328,6 +329,9 @@ fn index_mut(self, slice: &mut [T]) -> &mut [T] {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// The methods `index` and `index_mut` panic if:
|
||||||
|
/// - the start of the range is greater than the end of the range or
|
||||||
|
/// - the end of the range is out of bounds.
|
||||||
#[stable(feature = "slice_get_slice_impls", since = "1.15.0")]
|
#[stable(feature = "slice_get_slice_impls", since = "1.15.0")]
|
||||||
#[rustc_const_unstable(feature = "const_slice_index", issue = "none")]
|
#[rustc_const_unstable(feature = "const_slice_index", issue = "none")]
|
||||||
unsafe impl<T> SliceIndex<[T]> for ops::Range<usize> {
|
unsafe impl<T> SliceIndex<[T]> for ops::Range<usize> {
|
||||||
@ -416,6 +420,7 @@ fn index_mut(self, slice: &mut [T]) -> &mut [T] {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// The methods `index` and `index_mut` panic if the end of the range is out of bounds.
|
||||||
#[stable(feature = "slice_get_slice_impls", since = "1.15.0")]
|
#[stable(feature = "slice_get_slice_impls", since = "1.15.0")]
|
||||||
#[rustc_const_unstable(feature = "const_slice_index", issue = "none")]
|
#[rustc_const_unstable(feature = "const_slice_index", issue = "none")]
|
||||||
unsafe impl<T> SliceIndex<[T]> for ops::RangeTo<usize> {
|
unsafe impl<T> SliceIndex<[T]> for ops::RangeTo<usize> {
|
||||||
@ -454,6 +459,7 @@ fn index_mut(self, slice: &mut [T]) -> &mut [T] {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// The methods `index` and `index_mut` panic if the start of the range is out of bounds.
|
||||||
#[stable(feature = "slice_get_slice_impls", since = "1.15.0")]
|
#[stable(feature = "slice_get_slice_impls", since = "1.15.0")]
|
||||||
#[rustc_const_unstable(feature = "const_slice_index", issue = "none")]
|
#[rustc_const_unstable(feature = "const_slice_index", issue = "none")]
|
||||||
unsafe impl<T> SliceIndex<[T]> for ops::RangeFrom<usize> {
|
unsafe impl<T> SliceIndex<[T]> for ops::RangeFrom<usize> {
|
||||||
@ -536,6 +542,10 @@ fn index_mut(self, slice: &mut [T]) -> &mut [T] {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// The methods `index` and `index_mut` panic if:
|
||||||
|
/// - the end of the range is `usize::MAX` or
|
||||||
|
/// - the start of the range is greater than the end of the range or
|
||||||
|
/// - the end of the range is out of bounds.
|
||||||
#[stable(feature = "inclusive_range", since = "1.26.0")]
|
#[stable(feature = "inclusive_range", since = "1.26.0")]
|
||||||
#[rustc_const_unstable(feature = "const_slice_index", issue = "none")]
|
#[rustc_const_unstable(feature = "const_slice_index", issue = "none")]
|
||||||
unsafe impl<T> SliceIndex<[T]> for ops::RangeInclusive<usize> {
|
unsafe impl<T> SliceIndex<[T]> for ops::RangeInclusive<usize> {
|
||||||
@ -580,6 +590,7 @@ fn index_mut(self, slice: &mut [T]) -> &mut [T] {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// The methods `index` and `index_mut` panic if the end of the range is out of bounds.
|
||||||
#[stable(feature = "inclusive_range", since = "1.26.0")]
|
#[stable(feature = "inclusive_range", since = "1.26.0")]
|
||||||
#[rustc_const_unstable(feature = "const_slice_index", issue = "none")]
|
#[rustc_const_unstable(feature = "const_slice_index", issue = "none")]
|
||||||
unsafe impl<T> SliceIndex<[T]> for ops::RangeToInclusive<usize> {
|
unsafe impl<T> SliceIndex<[T]> for ops::RangeToInclusive<usize> {
|
||||||
|
Loading…
Reference in New Issue
Block a user