Skip to content

Commit

Permalink
Improve documentation of element_offset and related methods
Browse files Browse the repository at this point in the history
  • Loading branch information
wr7 authored and gitbot committed Feb 20, 2025
1 parent a59f3c7 commit b0c0bf1
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions core/src/slice/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4641,7 +4641,7 @@ impl<T> [T] {

/// Returns the index that an element reference points to.
///
/// Returns `None` if `element` does not point within the slice or if it points between elements.
/// Returns `None` if `element` does not point to the start of an element within the slice.
///
/// This method is useful for extending slice iterators like [`slice::split`].
///
Expand All @@ -4663,7 +4663,7 @@ impl<T> [T] {
/// assert_eq!(num, &1);
/// assert_eq!(nums.element_offset(num), Some(2));
/// ```
/// Returning `None` with an in-between element:
/// Returning `None` with an unaligned element:
/// ```
/// #![feature(substr_range)]
///
Expand Down Expand Up @@ -4702,7 +4702,8 @@ impl<T> [T] {

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

0 comments on commit b0c0bf1

Please sign in to comment.