From 4996edc53d69125e2f0828ce61206b1081ceda0c Mon Sep 17 00:00:00 2001 From: msmoiz Date: Thu, 13 Nov 2025 08:36:22 -0800 Subject: [PATCH 1/2] add note to `lines` docs about empty str behavior --- library/core/src/str/mod.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/library/core/src/str/mod.rs b/library/core/src/str/mod.rs index 45308c4b3e9c5..88d3cc8b5a6f9 100644 --- a/library/core/src/str/mod.rs +++ b/library/core/src/str/mod.rs @@ -1251,6 +1251,8 @@ impl str { /// ending will return the same lines as an otherwise identical string /// without a final line ending. /// + /// An empty string returns no lines. + /// /// # Examples /// /// Basic usage: @@ -1281,6 +1283,15 @@ impl str { /// /// assert_eq!(None, lines.next()); /// ``` + /// + /// An empty string returns no lines: + /// + /// ``` + /// let text = ""; + /// let mut lines = text.lines(); + /// + /// assert_eq!(lines.next(), None); + /// ``` #[stable(feature = "rust1", since = "1.0.0")] #[inline] pub fn lines(&self) -> Lines<'_> { From e628b059bbf99b7681a3147c2c4ecc151b5a7cd4 Mon Sep 17 00:00:00 2001 From: msmoiz Date: Thu, 13 Nov 2025 16:44:07 -0800 Subject: [PATCH 2/2] update language from "no lines" to "empty iterator" --- library/core/src/str/mod.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/library/core/src/str/mod.rs b/library/core/src/str/mod.rs index 88d3cc8b5a6f9..ab7389a1300c5 100644 --- a/library/core/src/str/mod.rs +++ b/library/core/src/str/mod.rs @@ -1251,7 +1251,7 @@ impl str { /// ending will return the same lines as an otherwise identical string /// without a final line ending. /// - /// An empty string returns no lines. + /// An empty string returns an empty iterator. /// /// # Examples /// @@ -1284,7 +1284,7 @@ impl str { /// assert_eq!(None, lines.next()); /// ``` /// - /// An empty string returns no lines: + /// An empty string returns an empty iterator: /// /// ``` /// let text = "";