default int forEachWithCount(Consumer<? super T> action) {
        Objects.requireNonNull(action, "Action required");
        try (ResultIterator<T> iter = iterator()) {
            int count = 0;
            while (iter.hasNext()) {
                count++;
                action.accept(iter.next());
            }
            return count;
        }
    }
Performs the specified action on each remaining element and returns the iteration i.e. record count.<br>
It is often useful (e.g. for logging) to know the record count while processing result sets.
<pre>
{@code
         int cnt = h.createQuery("select * from something").mapTo(String.class)
                    .forEachWithCount(System.out::println);
         System.out.println(cnt + " records selected");
       }
 </pre>

@param action action to apply (required)
@return iteration count

@since 3.31
core/src/main/java/org/jdbi/v3/core/result/ResultIterable.java