Skip to content

Commit b0c0bf1

Browse files
wr7gitbot
authored and
gitbot
committed
Improve documentation of element_offset and related methods
1 parent a59f3c7 commit b0c0bf1

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

core/src/slice/mod.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -4641,7 +4641,7 @@ impl<T> [T] {
46414641

46424642
/// Returns the index that an element reference points to.
46434643
///
4644-
/// Returns `None` if `element` does not point within the slice or if it points between elements.
4644+
/// Returns `None` if `element` does not point to the start of an element within the slice.
46454645
///
46464646
/// This method is useful for extending slice iterators like [`slice::split`].
46474647
///
@@ -4663,7 +4663,7 @@ impl<T> [T] {
46634663
/// assert_eq!(num, &1);
46644664
/// assert_eq!(nums.element_offset(num), Some(2));
46654665
/// ```
4666-
/// Returning `None` with an in-between element:
4666+
/// Returning `None` with an unaligned element:
46674667
/// ```
46684668
/// #![feature(substr_range)]
46694669
///
@@ -4702,7 +4702,8 @@ impl<T> [T] {
47024702

47034703
/// Returns the range of indices that a subslice points to.
47044704
///
4705-
/// Returns `None` if `subslice` does not point within the slice or if it points between elements.
4705+
/// Returns `None` if `subslice` does not point within the slice or if it is not aligned with the
4706+
/// elements in the slice.
47064707
///
47074708
/// This method **does not compare elements**. Instead, this method finds the location in the slice that
47084709
/// `subslice` was obtained from. To find the index of a subslice via comparison, instead use

0 commit comments

Comments
 (0)