Why doesn't `io::stdin().lock().lines().count()` work?

Equivalent code (without type qualifiers fixed in place.)

count(lines(lock(io::stdin())));

Once the call to lock function completes its return value is passes as parameter to lines but all parameters used passed to lock stop being in use. Locks return value though is linked to the lifetime of its parameter.

1 Like