Give into_range more consistent name
Rename `into_range` to `try_into_slice_range`: - Prepend `try_` to show that it returns `None` on error, like `try_range` - add `_slice` to make it consistent with `into_slice_range`
This commit is contained in:
parent
94ff542ff5
commit
f8cf68f35a
2 changed files with 6 additions and 6 deletions
|
|
@ -949,7 +949,7 @@ where
|
||||||
R: ops::RangeBounds<usize>,
|
R: ops::RangeBounds<usize>,
|
||||||
{
|
{
|
||||||
let len = bounds.end;
|
let len = bounds.end;
|
||||||
into_range(len, (range.start_bound().copied(), range.end_bound().copied()))
|
try_into_slice_range(len, (range.start_bound().copied(), range.end_bound().copied()))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Converts a pair of `ops::Bound`s into `ops::Range` without performing any
|
/// Converts a pair of `ops::Bound`s into `ops::Range` without performing any
|
||||||
|
|
@ -976,7 +976,7 @@ pub(crate) const fn into_range_unchecked(
|
||||||
/// Returns `None` on overflowing indices.
|
/// Returns `None` on overflowing indices.
|
||||||
#[rustc_const_unstable(feature = "const_range", issue = "none")]
|
#[rustc_const_unstable(feature = "const_range", issue = "none")]
|
||||||
#[inline]
|
#[inline]
|
||||||
pub(crate) const fn into_range(
|
pub(crate) const fn try_into_slice_range(
|
||||||
len: usize,
|
len: usize,
|
||||||
(start, end): (ops::Bound<usize>, ops::Bound<usize>),
|
(start, end): (ops::Bound<usize>, ops::Bound<usize>),
|
||||||
) -> Option<ops::Range<usize>> {
|
) -> Option<ops::Range<usize>> {
|
||||||
|
|
@ -1043,12 +1043,12 @@ unsafe impl<T> SliceIndex<[T]> for (ops::Bound<usize>, ops::Bound<usize>) {
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn get(self, slice: &[T]) -> Option<&Self::Output> {
|
fn get(self, slice: &[T]) -> Option<&Self::Output> {
|
||||||
into_range(slice.len(), self)?.get(slice)
|
try_into_slice_range(slice.len(), self)?.get(slice)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn get_mut(self, slice: &mut [T]) -> Option<&mut Self::Output> {
|
fn get_mut(self, slice: &mut [T]) -> Option<&mut Self::Output> {
|
||||||
into_range(slice.len(), self)?.get_mut(slice)
|
try_into_slice_range(slice.len(), self)?.get_mut(slice)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
|
|
|
||||||
|
|
@ -382,12 +382,12 @@ unsafe impl SliceIndex<str> for (ops::Bound<usize>, ops::Bound<usize>) {
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn get(self, slice: &str) -> Option<&str> {
|
fn get(self, slice: &str) -> Option<&str> {
|
||||||
crate::slice::index::into_range(slice.len(), self)?.get(slice)
|
crate::slice::index::try_into_slice_range(slice.len(), self)?.get(slice)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn get_mut(self, slice: &mut str) -> Option<&mut str> {
|
fn get_mut(self, slice: &mut str) -> Option<&mut str> {
|
||||||
crate::slice::index::into_range(slice.len(), self)?.get_mut(slice)
|
crate::slice::index::try_into_slice_range(slice.len(), self)?.get_mut(slice)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue