Skip to content

Commit 2cc10ce

Browse files
committed
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`
1 parent e397155 commit 2cc10ce

2 files changed

Lines changed: 6 additions & 6 deletions

File tree

library/core/src/slice/index.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -949,7 +949,7 @@ where
949949
R: ops::RangeBounds<usize>,
950950
{
951951
let len = bounds.end;
952-
into_range(len, (range.start_bound().copied(), range.end_bound().copied()))
952+
try_into_slice_range(len, (range.start_bound().copied(), range.end_bound().copied()))
953953
}
954954

955955
/// Converts a pair of `ops::Bound`s into `ops::Range` without performing any
@@ -976,7 +976,7 @@ pub(crate) const fn into_range_unchecked(
976976
/// Returns `None` on overflowing indices.
977977
#[rustc_const_unstable(feature = "const_range", issue = "none")]
978978
#[inline]
979-
pub(crate) const fn into_range(
979+
pub(crate) const fn try_into_slice_range(
980980
len: usize,
981981
(start, end): (ops::Bound<usize>, ops::Bound<usize>),
982982
) -> Option<ops::Range<usize>> {
@@ -1043,12 +1043,12 @@ unsafe impl<T> SliceIndex<[T]> for (ops::Bound<usize>, ops::Bound<usize>) {
10431043

10441044
#[inline]
10451045
fn get(self, slice: &[T]) -> Option<&Self::Output> {
1046-
into_range(slice.len(), self)?.get(slice)
1046+
try_into_slice_range(slice.len(), self)?.get(slice)
10471047
}
10481048

10491049
#[inline]
10501050
fn get_mut(self, slice: &mut [T]) -> Option<&mut Self::Output> {
1051-
into_range(slice.len(), self)?.get_mut(slice)
1051+
try_into_slice_range(slice.len(), self)?.get_mut(slice)
10521052
}
10531053

10541054
#[inline]

library/core/src/str/traits.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -382,12 +382,12 @@ unsafe impl SliceIndex<str> for (ops::Bound<usize>, ops::Bound<usize>) {
382382

383383
#[inline]
384384
fn get(self, slice: &str) -> Option<&str> {
385-
crate::slice::index::into_range(slice.len(), self)?.get(slice)
385+
crate::slice::index::try_into_slice_range(slice.len(), self)?.get(slice)
386386
}
387387

388388
#[inline]
389389
fn get_mut(self, slice: &mut str) -> Option<&mut str> {
390-
crate::slice::index::into_range(slice.len(), self)?.get_mut(slice)
390+
crate::slice::index::try_into_slice_range(slice.len(), self)?.get_mut(slice)
391391
}
392392

393393
#[inline]

0 commit comments

Comments
 (0)