about summary refs log tree commit diff
diff options
context:
space:
mode:
authorYuki Okushi <huyuumi.dev+love@gmail.com>2022-12-22 08:32:10 +0900
committerGitHub <noreply@github.com>2022-12-22 08:32:10 +0900
commit257edf2de50c9a0d18c86146fb20aa39ff2ff89b (patch)
tree178e488d70c3e682964412b3b1d1ee67c8ad1249
parent4f29ca386f83c1ac3a2c5f4a721c5533ab97f586 (diff)
parent7f9438910c2c86813b597dfc518990198691d170 (diff)
downloadrust-257edf2de50c9a0d18c86146fb20aa39ff2ff89b.tar.gz
rust-257edf2de50c9a0d18c86146fb20aa39ff2ff89b.zip
Rollup merge of #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.
-rw-r--r--library/core/src/str/mod.rs6
1 files changed, 4 insertions, 2 deletions
diff --git a/library/core/src/str/mod.rs b/library/core/src/str/mod.rs
index 45fd2caae52..863ded5e5ec 100644
--- a/library/core/src/str/mod.rs
+++ b/library/core/src/str/mod.rs
@@ -970,8 +970,10 @@ impl str {
 
     /// 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