public static function indexOf(Iterator $iterator, callable $predicate) : int
    {
        $i = 0;
        while ($iterator->valid()) {
            if (Predicates::call($predicate, $iterator->current())) {
                return $i;
            }
            $i++;
            $iterator->next();
        }
        return -1;
    }