You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As stated here, Lines can enter an infinite loop if nothing like map_while is used when used on directory. Therefore something like lines().count() may enter an infinite loop. Therefore, it would be good if a warn can be added to fix like : lines().map_while(Result::ok).count().
Advantage
It will avoid entering a loop when used on directory in certain platforms.
Drawbacks
Some users may be interested in getting the count with lines with errors included.
Example
let linecount = BufReader::new(File::open("some-path")?).lines().count();
Could be warned and this used instead :
let linecount = BufReader::new(File::open("some-path")?).lines().map_while(Result::ok).count();
The text was updated successfully, but these errors were encountered:
+1 to the idea of having a lint on Iterator<Item = Result<_, _>>::count. I'd prefer the suggested alternative be to bubble up the error rather than swallow it.
Uh oh!
There was an error while loading. Please reload this page.
What it does
As stated here, Lines can enter an infinite loop if nothing like
map_while
is used when used on directory. Therefore something likelines().count()
may enter an infinite loop. Therefore, it would be good if a warn can be added to fix like :lines().map_while(Result::ok).count()
.Advantage
Drawbacks
Example
Could be warned and this used instead :
The text was updated successfully, but these errors were encountered: