When some of the values generated by a generator created by Gn are not consumed, a warning appears in the logs.
I assumed this warning is erroneous, and should at most be a trace!() if any.
use generator::*;
// This generator seems totally fine
fn generate_values(start: u8) -> impl Iterator<Item = u8> {
Gn::new_scoped(move |mut s| { // The warning will only appears if it's a moved closure
for i in start..20 {
s.yield_(i);
}
done!()
})
}
fn main() {
env_logger::init();
let _: Vec<_> = dbg!(
generate_values(3).
.take(3) // this will abort the generator early
.collect());
}
$ RUST_LOG=trace cargo run
[2020-07-24T15:45:33Z WARN generator::gen_impl] generator is not done while drop
[src/main.rs:26] foo(3).take(3).collect() = [
3,
4,
5,
]
When some of the values generated by a generator created by
Gn
are not consumed, a warning appears in the logs.I assumed this warning is erroneous, and should at most be a
trace!()
if any.