-
Notifications
You must be signed in to change notification settings - Fork 13.3k
str: Implement str::trim_newline #91047
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
Conversation
(rust-highfive has picked a reviewer for you, use r? to override) |
Obviously, if the basic idea seems good I will open the tracking issue and update the MR branch. |
This test will fail: assert_eq!("Text", "Text\n\r".trim_newline()); Ahh,
ok then. |
This comment has been minimized.
This comment has been minimized.
Sadly there doesn't seem to be a way to do this right now.
Indeed. Your response seems to me to demonstrate that the docs needed improving :-). I have added the actual handling of this, with a note, to the example.
|
Apropos discussion here rust-lang#91047 (comment) Sadly, str::lines gets this wrong. I think it is probably too late to fix this, so document it instead.
Ping from triage: |
Closing this as inactive |
This function was contemplated here rust-lang/rfcs#3196 (comment)
It seems like a good idea to me. I chose to call it
trim_newline
rather thantrim_end_newline
since trimming newlines anywhere else would be weird, soend
felt redundant.I have not provided a method on
String
as contemplated in that issue. We don't have any other mutating versions ofstr
trimming methods, so everyone who wants that has to writes.truncate(s.trim_wombat().len())
. I think that's OK since it is more idiomatic to work with slices.