Skip to content

Commit 4996edc

Browse files
committed
add note to lines docs about empty str behavior
1 parent d682af8 commit 4996edc

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

library/core/src/str/mod.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1251,6 +1251,8 @@ impl str {
12511251
/// ending will return the same lines as an otherwise identical string
12521252
/// without a final line ending.
12531253
///
1254+
/// An empty string returns no lines.
1255+
///
12541256
/// # Examples
12551257
///
12561258
/// Basic usage:
@@ -1281,6 +1283,15 @@ impl str {
12811283
///
12821284
/// assert_eq!(None, lines.next());
12831285
/// ```
1286+
///
1287+
/// An empty string returns no lines:
1288+
///
1289+
/// ```
1290+
/// let text = "";
1291+
/// let mut lines = text.lines();
1292+
///
1293+
/// assert_eq!(lines.next(), None);
1294+
/// ```
12841295
#[stable(feature = "rust1", since = "1.0.0")]
12851296
#[inline]
12861297
pub fn lines(&self) -> Lines<'_> {

0 commit comments

Comments
 (0)