Function partition
pub(crate) fn partition<T, F>(v: &mut [T], pivot: usize, is_less: &mut F) -> usize
where
F: FnMut(&T, &T) -> bool,
Takes the input slice v and re-arranges elements such that when the call returns normally
all elements that compare true for is_less(elem, pivot) where pivot == v[pivot_pos] are
on the left side of v followed by the other elements, notionally considered greater or
equal to pivot.
Returns the number of elements that are compared true for is_less(elem, pivot).
If is_less does not implement a total order the resulting order and return value are
unspecified. All original elements will remain in v and any possible modifications via
interior mutability will be observable. Same is true if is_less panics or v.len()
exceeds scratch.len().