Skip to content

Commit

Permalink
More clearly document Stdin::read_line
Browse files Browse the repository at this point in the history
These are common pitfalls for beginners, so I think it's worth
making the subtleties more visible.
  • Loading branch information
theemathas committed Oct 10, 2024
1 parent 4cc494b commit 2035737
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion library/std/src/io/stdio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,12 @@ impl Stdin {
/// Locks this handle and reads a line of input, appending it to the specified buffer.
///
/// For detailed semantics of this method, see the documentation on
/// [`BufRead::read_line`].
/// [`BufRead::read_line`]. In particular:
/// * Previous content of the buffer will be preserved. To avoid appending
/// to the buffer, you need to [`clear`] it first.
/// * The trailing newline character, if any, is included in the buffer.
///
/// [`clear`]: String::clear
///
/// # Examples
///
Expand Down

0 comments on commit 2035737

Please sign in to comment.