Skip to content

Commit 335abd3

Browse files
wr7gitbot
authored andcommitted
Improve documentation of element_offset and related methods
1 parent 43f555b commit 335abd3

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

core/src/slice/mod.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4551,7 +4551,7 @@ impl<T> [T] {
45514551

45524552
/// Returns the index that an element reference points to.
45534553
///
4554-
/// Returns `None` if `element` does not point within the slice or if it points between elements.
4554+
/// Returns `None` if `element` does not point to the start of an element within the slice.
45554555
///
45564556
/// This method is useful for extending slice iterators like [`slice::split`].
45574557
///
@@ -4573,7 +4573,7 @@ impl<T> [T] {
45734573
/// assert_eq!(num, &1);
45744574
/// assert_eq!(nums.element_offset(num), Some(2));
45754575
/// ```
4576-
/// Returning `None` with an in-between element:
4576+
/// Returning `None` with an unaligned element:
45774577
/// ```
45784578
/// #![feature(substr_range)]
45794579
///
@@ -4612,7 +4612,8 @@ impl<T> [T] {
46124612

46134613
/// Returns the range of indices that a subslice points to.
46144614
///
4615-
/// Returns `None` if `subslice` does not point within the slice or if it points between elements.
4615+
/// Returns `None` if `subslice` does not point within the slice or if it is not aligned with the
4616+
/// elements in the slice.
46164617
///
46174618
/// This method **does not compare elements**. Instead, this method finds the location in the slice that
46184619
/// `subslice` was obtained from. To find the index of a subslice via comparison, instead use

0 commit comments

Comments
 (0)