/*
 *  call-seq:
 *    e.with_index {|(*args), idx| ... }
 *
 *  Iterates the given block for each elements with an index, which
 *  start from 0.
 *
 */
static VALUE
enumerator_with_index(VALUE obj)
{
    struct enumerator *e = enumerator_ptr(obj);
    VALUE memo = 0;
    int argc = 0;
    VALUE *argv = 0;

    if (e->args) {
        argc = RARRAY(e->args)->len;
        argv = RARRAY(e->args)->ptr;
    }
    return rb_block_call(e->method, rb_intern("call"), argc, argv,
                         enumerator_with_index_i, (VALUE)&memo);
}