Skip to content

Commit f610be3

Browse files
authored
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.
1 parent 198acf9 commit f610be3

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

core/src/str/mod.rs

Lines changed: 4 additions & 2 deletions
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)