Skip to content
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

std: Account for CRLF in {str, BufRead}::lines #28034

Merged
merged 1 commit into from Sep 4, 2015

Conversation

alexcrichton
Copy link
Member

This commit is an implementation of RFC 1212 which tweaks the behavior of
the str::lines and BufRead::lines iterators. Both iterators now account for
\r\n sequences in addition to \n, allowing for less surprising behavior
across platforms (especially in the BufRead case). Splitting only on the
\n character can still be achieved with split('\n') in both cases.

The str::lines_any function is also now deprecated as str::lines is a
drop-in replacement for it.

Closes #28032

@rust-highfive
Copy link
Collaborator

r? @brson

(rust_highfive has picked a reviewer for you, use r? to override)

///
/// This does not include the empty string after a trailing `\n`.
/// This does not include the empty string after a trailing newline or CRLF.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should clarify (like the BufRead one does) that the newlines are stripped from the strings that are yielded.

@brson
Copy link
Contributor

brson commented Aug 27, 2015

How should this change be publicized? Since it's silently breaking we need to spread the word to prevent surprises.

@brson
Copy link
Contributor

brson commented Aug 28, 2015

Based on this comment I can't tell what you think of this immediate deprecation. It sounds to me that you agree we should not deprecate it now but want to anyway.

@alexcrichton
Copy link
Member Author

I want to deprecate it now. I understand that it'll be annoying but I don't want to prevent this and all future deprecations until we have a system in place for delaying deprecation warnings.

@aturon
Copy link
Member

aturon commented Sep 3, 2015

@bors: r+

@bors
Copy link
Contributor

bors commented Sep 3, 2015

📌 Commit 76011a2 has been approved by aturon

@aturon
Copy link
Member

aturon commented Sep 3, 2015

On the issue of deprecation timing: it's more relevant when we're introducing a new stable function. In this case, we're deprecating in favor of an existing function, and we should give people a heads-up about this new behavior ASAP.

As far as announcing this goes, I think we should send a blast on all of our usual channels (reddit, discuss, twitter, IRC) once it lands, and then highlight it in the relnotes. I'm tagging accordingly.

@aturon aturon added the relnotes Marks issues that should be documented in the release notes of the next release. label Sep 3, 2015
@bors
Copy link
Contributor

bors commented Sep 4, 2015

☔ The latest upstream changes (presumably #28200) made this pull request unmergeable. Please resolve the merge conflicts.

This commit is an implementation of [RFC 1212][rfc] which tweaks the behavior of
the `str::lines` and `BufRead::lines` iterators. Both iterators now account for
`\r\n` sequences in addition to `\n`, allowing for less surprising behavior
across platforms (especially in the `BufRead` case). Splitting *only* on the
`\n` character can still be achieved with `split('\n')` in both cases.

The `str::lines_any` function is also now deprecated as `str::lines` is a
drop-in replacement for it.

[rfc]: https://github.com/rust-lang/rfcs/blob/master/text/1212-line-endings.md

Closes rust-lang#28032
@alexcrichton
Copy link
Member Author

@bors: r=aturon 48615a6

@bors
Copy link
Contributor

bors commented Sep 4, 2015

⌛ Testing commit 48615a6 with merge b4de424...

bors added a commit that referenced this pull request Sep 4, 2015
This commit is an implementation of [RFC 1212][rfc] which tweaks the behavior of
the `str::lines` and `BufRead::lines` iterators. Both iterators now account for
`\r\n` sequences in addition to `\n`, allowing for less surprising behavior
across platforms (especially in the `BufRead` case). Splitting *only* on the
`\n` character can still be achieved with `split('\n')` in both cases.

The `str::lines_any` function is also now deprecated as `str::lines` is a
drop-in replacement for it.

[rfc]: https://github.com/rust-lang/rfcs/blob/master/text/1212-line-endings.md

Closes #28032
@bors bors merged commit 48615a6 into rust-lang:master Sep 4, 2015
@alexcrichton alexcrichton deleted the new-lines branch September 4, 2015 16:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
relnotes Marks issues that should be documented in the release notes of the next release.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants