Skip to content

Commit 3c8bfb7

Browse files
committed
Improve documentation of element_offset and related methods
1 parent b8407d9 commit 3c8bfb7

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

library/core/src/slice/mod.rs

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

45344534
/// Returns the index that an element reference points to.
45354535
///
4536-
/// Returns `None` if `element` does not point within the slice or if it points between elements.
4536+
/// Returns `None` if `element` does not point to the start of an element within the slice.
45374537
///
45384538
/// This method is useful for extending slice iterators like [`slice::split`].
45394539
///
@@ -4555,7 +4555,7 @@ impl<T> [T] {
45554555
/// assert_eq!(num, &1);
45564556
/// assert_eq!(nums.element_offset(num), Some(2));
45574557
/// ```
4558-
/// Returning `None` with an in-between element:
4558+
/// Returning `None` with an unaligned element:
45594559
/// ```
45604560
/// #![feature(substr_range)]
45614561
///
@@ -4594,7 +4594,8 @@ impl<T> [T] {
45944594

45954595
/// Returns the range of indices that a subslice points to.
45964596
///
4597-
/// Returns `None` if `subslice` does not point within the slice or if it points between elements.
4597+
/// Returns `None` if `subslice` does not point within the slice or if it is not aligned with the
4598+
/// elements in the slice.
45984599
///
45994600
/// This method **does not compare elements**. Instead, this method finds the location in the slice that
46004601
/// `subslice` was obtained from. To find the index of a subslice via comparison, instead use

0 commit comments

Comments
 (0)