pub fn find_in_direction<T, F, R>(
    items: &[T],
    current_index: usize,
    direction: SearchDirection,
    predicate: F
) -> Option<(usize, R)>where
    F: Fn(&T) -> Option<R>,
Expand description

Searches for an item in a slice in a specified direction and returns the first item that matches the provided predicate.

Arguments

  • items - The list of items to search.
  • current_index - The index to start the search from.
  • direction - The direction to search in.
  • predicate - A function that takes an item and returns an Option<R>. When this function returns Some(R), the item is considered a match.

Returns

Returns a tuple of the index and the result R of the predicate for the first item that matches.