-
Notifications
You must be signed in to change notification settings - Fork 12.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
str::lines consumes carriage returns at the end of a line which is undocumented #94435
Labels
C-bug
Category: This is a bug.
Comments
There is a PR for it: #91191 |
KamilaBorowska
added a commit
to KamilaBorowska/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 <[email protected]>
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.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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: