Problem
CursorBatch::rows(), declared as pub fn rows(&self) -> impl Iterator<Item = Result<&'a RawDocument>>, captures &self in its returned impl Iterator in addition to the 'a lifetime it's parameterized over. Under Rust 2024's capture rules, code like match batch.rows().next() { ... } in tail position fails to compile with E0597 ("borrowed value does not live long enough").
Why it matters
Perry's P7 lane calls this "a one-line fix that will otherwise bite every host" of turnloop-mongodb compiled under Rust 2024 — rustc itself suggests the fix.
What would fix it
Adding + use<'a> to the impl Iterator return type, exactly as rustc's own diagnostic suggests, so the returned iterator only captures the lifetime it actually needs rather than also capturing &self.
Problem
CursorBatch::rows(), declared aspub fn rows(&self) -> impl Iterator<Item = Result<&'a RawDocument>>, captures&selfin its returnedimpl Iteratorin addition to the'alifetime it's parameterized over. Under Rust 2024's capture rules, code likematch batch.rows().next() { ... }in tail position fails to compile with E0597 ("borrowed value does not live long enough").Why it matters
Perry's P7 lane calls this "a one-line fix that will otherwise bite every host" of
turnloop-mongodbcompiled under Rust 2024 — rustc itself suggests the fix.What would fix it
Adding
+ use<'a>to theimpl Iteratorreturn type, exactly as rustc's own diagnostic suggests, so the returned iterator only captures the lifetime it actually needs rather than also capturing&self.