Skip to content

Commit 113c6c0

Browse files
authored
Rollup merge of rust-lang#131503 - theemathas:stdin_read_line_docs, r=Mark-Simulacrum
More clearly document Stdin::read_line These are common pitfalls for beginners, so I think it's worth making the subtleties more visible.
2 parents 7420c36 + fca0919 commit 113c6c0

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

std/src/io/stdio.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,12 @@ impl Stdin {
370370
/// Locks this handle and reads a line of input, appending it to the specified buffer.
371371
///
372372
/// For detailed semantics of this method, see the documentation on
373-
/// [`BufRead::read_line`].
373+
/// [`BufRead::read_line`]. In particular:
374+
/// * Previous content of the buffer will be preserved. To avoid appending
375+
/// to the buffer, you need to [`clear`] it first.
376+
/// * The trailing newline character, if any, is included in the buffer.
377+
///
378+
/// [`clear`]: String::clear
374379
///
375380
/// # Examples
376381
///

0 commit comments

Comments
 (0)