rsplitOnce method

Option<(Slice<T>, Slice<T>)> rsplitOnce(
  1. bool pred(
    1. T
    )
)

Splits the slice on the last element that matches the specified predicate. If any matching elements are resent in the slice, returns the prefix before the match and suffix after. The matching element itself is not included. If no elements match, returns None.

Implementation

Option<(Slice<T>, Slice<T>)> rsplitOnce(bool Function(T) pred) {
  var index = _end - 1;
  while (index >= _start) {
    if (pred(_list[index])) {
      return Some(
          (Slice(_list, _start, index), Slice(_list, index + 1, _end)));
    }
    index--;
  }
  return None;
}