Skip to content

Commit 7bdef9e

Browse files
authored
Rollup merge of rust-lang#105824 - zacchiro:patch-1, r=JohnTitor
str.lines() docstring: clarify that line endings are not returned Previously, the str.lines() docstring stated that lines are split at line endings, but not whether those were returned or not. This new version of the docstring states this explicitly, avoiding the need of getting to doctests to get an answer to this FAQ.
2 parents 0d92836 + 7f94389 commit 7bdef9e

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

library/core/src/str/mod.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -970,8 +970,10 @@ impl str {
970970

971971
/// An iterator over the lines of a string, as string slices.
972972
///
973-
/// Lines are ended with either a newline (`\n`) or a carriage return with
974-
/// a line feed (`\r\n`).
973+
/// Lines are split at line endings that are either newlines (`\n`) or
974+
/// sequences of a carriage return followed by a line feed (`\r\n`).
975+
///
976+
/// Line terminators are not included in the lines returned by the iterator.
975977
///
976978
/// The final line ending is optional. A string that ends with a final line
977979
/// ending will return the same lines as an otherwise identical string

0 commit comments

Comments
 (0)