diff options
| author | Tim (Theemathas) Chirananthavat <theemathas@gmail.com> | 2024-10-10 23:12:03 +0700 | 
|---|---|---|
| committer | Tim (Theemathas) Chirananthavat <theemathas@gmail.com> | 2024-10-10 23:12:03 +0700 | 
| commit | 203573701a186490db661f52bbf852906d45a2fb (patch) | |
| tree | e47fee8de06592570cdd6bac92c59e5a14c138b9 /library/std/src/io/stdio.rs | |
| parent | 4cc494bbfe9911d24f3ee521f98d5c6bb7e3ffe8 (diff) | |
| download | rust-203573701a186490db661f52bbf852906d45a2fb.tar.gz rust-203573701a186490db661f52bbf852906d45a2fb.zip | |
More clearly document Stdin::read_line
These are common pitfalls for beginners, so I think it's worth making the subtleties more visible.
Diffstat (limited to 'library/std/src/io/stdio.rs')
| -rw-r--r-- | library/std/src/io/stdio.rs | 7 | 
1 files changed, 6 insertions, 1 deletions
| diff --git a/library/std/src/io/stdio.rs b/library/std/src/io/stdio.rs index bf242e715bd..35b38ed783f 100644 --- a/library/std/src/io/stdio.rs +++ b/library/std/src/io/stdio.rs @@ -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 /// | 
