-
Notifications
You must be signed in to change notification settings - Fork 13.1k
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
Unify "str::lines()" and "str::lines_any()" and make it Unicode-correct #1557
Comments
There is no 'right thing' when it comes to line splitting, which I assume is exactly the reason Kevin implemented both of these functions. The document you're linking appears to have very little to do with the problem these functions solve -- it relates to breaking lines, not splitting by line. |
Feel free to discuss, or even reopen if you feel I missed something. Programming languages can not solve the problem of there being different line ending conventions or the fact that programmers will have to think about how they want to be splitting lines. Thus, I think the current provisions in the |
The document says: "Otherwise, the following recommendations specify how to cope with an NLF [...] when interpreting characters in text". And Haskell's Since i lack the rights to reopen, i leave it up to the others. |
Haskell's |
Your are correct,
http://www.haskell.org/ghc/docs/6.12.2/html/libraries/base-4.2.0.1/System-IO.html#25 I'd prefer it when users would not have to care about CR, LF, CRLF and NEL. Are there use cases when you want to split only on |
I think it would be worth abstracting away the different types of line endings. At the very least, if you want both functionalities, have the more commonly used function (str::lines) abstract away the line-endings, and then have another function that only splits on newlines. str::lines should split on any line feed character. If you want to split only on newlines, you would likely just use a "split" function and put the '\n' character as the character to split on. |
…#1556) (rust-lang#1557) Co-authored-by: Yuki Okushi <jtitor@2k36.org> Closes rust-lang/rustc-dev-guide#1556
…#1556) (rust-lang#1557) Co-authored-by: Yuki Okushi <jtitor@2k36.org> Closes rust-lang/rustc-dev-guide#1556
str::lines()
appears to split strings only on\n
str::lines_any()
appears to split on\n
and on\r\n
.I think, we want only one function doing "the right thing (tm)".
See
The text was updated successfully, but these errors were encountered: