tinaun / gen-iter

create iterators from generators
Apache License 2.0
11 stars 6 forks source link

`GenIter` is panicking after call `.next()` after completion #7

Open uselessgoddess opened 2 years ago

uselessgoddess commented 2 years ago

Your generator is panicking thread 'main' panicked at 'generator resumed after completion'

let mut generator = gen_iter! {{
    yield 1;
}};

println!("{:?}", generator.next());
println!("{:?}", generator.next());
println!("{:?}", generator.next());
viruscamp commented 1 year ago

It was designed as this, to minimize the memory footprint of GenIter<T>. It's recommended to use GenIter<T> in for loop instead of call next manually.

Boscop commented 1 year ago

@uselessgoddess What if you call .fuse() on the iterator, does it still panic if you keep calling next?