Skip to content

Add explicit lifetime parameters to reader iterator trait, allows use of &mut instead of move

Michael Aaron Murphy requested to merge mhintz:input-iterator-fix into master

Created by: mhintz

So that the input reader iterators can be used in places where a move is not possible and where constantly reinstantiating is not feasible. This change was prompted by needing to work with keyboard input inside of a main loop of a program, without being able to use the normal (synchronous) loop because it blocks. I had tried calling async_stdin() on every loop iteration, but in addition to being probably quite expensive, that function panics every now and again because sometimes stdin isn't available, and an Error is unwrapped in get_tty(). I don't think this changes the external-facing API at all, simply allows a slightly looser use of the main stream because &mut is more flexible than a move.

Merge request reports