fn take_matching_index<T>( values: &[T], consumed: &mut [bool], predicate: impl Fn(&T) -> bool, ) -> Option<usize>