Why is this argument borrowed forever – only when by a trait object?

Your fix...

fn chunk_results<'x>(&'x self, stream: &'x mut F) -> Box<dyn 'x ..>

...is probably what you want (without further redesign anyway).

But if you want to read more about the error, it's basically the same as what I'm talking about in this comment. Just replace Chars<'c> with &'f File or so.

Thus this also is a workaround for the OP...

//                        vvvvvvv               vv
let iter_builder: Box<dyn for<'f> ReduceChunks<&'f File>> = Box::new(ChunkSummer {});

...but improving the trait/method is probably the better fix.

1 Like