Add lines_any
to BufRead
(mirroring str
)
#1188
Labels
T-libs-api
Relevant to the library API team, which will review and decide on the RFC.
Currently, both
str
andBufRead
provide a functionlines()
to iterate over lines as separated by\n
.str
also provideslines_any()
to recognize both\n
and\r\n
as line separator. This is very useful, e.g. to iterate over the lines ofstdin
and get the same behavior across platforms. Hence I thinkBufRead
should havelines_any()
as well.I'm currently trying to implement this myself.
Note: I think it would be even better if
lines()
properly recognized both kinds of line-endings. That's certainly the more common operation. I can hardly imagine a good reason for wanting to split only some kinds of lines - and if one needs that, a generic "split at this byte" would have "split at\n
" as an instance.Would it violate Rust's compatibility promise to change
lines()
to properly recognize both kinds of line endings?The text was updated successfully, but these errors were encountered: