]> git.lizzy.rs Git - rust.git/commitdiff
str.lines() docstring: clarify that line endings are not returned
authorStefano Zacchiroli <zack@upsilon.cc>
Sat, 17 Dec 2022 11:20:56 +0000 (12:20 +0100)
committerGitHub <noreply@github.com>
Sat, 17 Dec 2022 11:20:56 +0000 (12:20 +0100)
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.

library/core/src/str/mod.rs

index 45fd2caae52f4f27efe70ac4054c9660fc3bec99..863ded5e5ec037836586366e1ac2a2a41a3bbe02 100644 (file)
@@ -970,8 +970,10 @@ pub fn split_ascii_whitespace(&self) -> SplitAsciiWhitespace<'_> {
 
     /// An iterator over the lines of a string, as string slices.
     ///
-    /// Lines are ended with either a newline (`\n`) or a carriage return with
-    /// a line feed (`\r\n`).
+    /// Lines are split at line endings that are either newlines (`\n`) or
+    /// sequences of a carriage return followed by a line feed (`\r\n`).
+    ///
+    /// Line terminators are not included in the lines returned by the iterator.
     ///
     /// The final line ending is optional. A string that ends with a final line
     /// ending will return the same lines as an otherwise identical string