I just used binary_search inside a loop and realized that it would be nice to check before the loop if my immutable slice was sorted. So I spent 10 minutes going through the standard library just to find out that there aren't any is_sorted, is_sorted_by, is_sorted_by_key, etc. algorithms implemented for neither slices nor iterators.
We should add:
and since Iterator is implemented for slices, we can add those methods to slices as well by just forwarding to the Iterator implementation.
I just used
binary_searchinside a loop and realized that it would be nice to check before the loop if my immutable slice was sorted. So I spent 10 minutes going through the standard library just to find out that there aren't anyis_sorted,is_sorted_by,is_sorted_by_key, etc. algorithms implemented for neither slices nor iterators.We should add:
Iterator::is_sortedIterator::is_sorted_byIterator::is_sorted_by_keyand since
Iteratoris implemented for slices, we can add those methods to slices as well by just forwarding to theIteratorimplementation.