-
Notifications
You must be signed in to change notification settings - Fork 13.4k
str::lines consumes carriage returns at the end of a line which is undocumented #94435
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Labels
C-bug
Category: This is a bug.
Comments
There is a PR for it: #91191 |
LunaBorowska
added a commit
to LunaBorowska/rust
that referenced
this issue
Aug 9, 2022
Previously "bare\r" was split into ["bare"] even though the documentation said that only LF and CRLF count as newlines. This fix is a behavioural change, even though it brings the behaviour into line with the documentation, and into line with that of `std::io::BufRead::lines()`. This is an alternative to rust-lang#91051, which proposes to document rather than fix the behaviour. Fixes rust-lang#94435. Co-authored-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
matthiaskrgr
added a commit
to matthiaskrgr/rust
that referenced
this issue
Oct 3, 2022
…, r=joshtriplett Fix handling of trailing bare CR in str::lines Continuing from rust-lang#91191. Fixes rust-lang#94435.
Dylan-DPC
added a commit
to Dylan-DPC/rust
that referenced
this issue
Mar 22, 2023
…, r=ChrisDenton Fix handling of trailing bare CR in str::lines Continuing from rust-lang#91191. Fixes rust-lang#94435.
Dylan-DPC
added a commit
to Dylan-DPC/rust
that referenced
this issue
Mar 22, 2023
…, r=ChrisDenton Fix handling of trailing bare CR in str::lines Continuing from rust-lang#91191. Fixes rust-lang#94435.
# for free
to join this conversation on GitHub.
Already have an account?
# to comment
Uh oh!
There was an error while loading. Please reload this page.
I tried this code:
I expected to see this happen:
"a\r"
to be printed.Instead, this happened:
"a"
is being printed.At this point fixing this behavior may break actual code (and this would be a quiet change), however documenting this may make sense. This behavior was introduced in Rust 1.4.0 as a result of implementation of RFC 1212.
Curiously,
BufRead::lines
whose behavior was changed by the same RFC doesn't have this issue. It makes sure that\r
is followed by\n
before deleting the carriage return.Meta
rustc --version --verbose
:The text was updated successfully, but these errors were encountered: