diff options
| author | Kornel <kornel@geekhood.net> | 2023-01-01 17:49:05 +0000 |
|---|---|---|
| committer | Kornel <kornel@geekhood.net> | 2023-01-01 17:49:05 +0000 |
| commit | 1a983536f3ee798b18224658d5d4b406c952c64d (patch) | |
| tree | 67f27613c1d3b8c4ecf9f380430497977114c277 /library/std/src | |
| parent | bb6e76df06dcbdb96e634eb28a49f161d70ab844 (diff) | |
| download | rust-1a983536f3ee798b18224658d5d4b406c952c64d.tar.gz rust-1a983536f3ee798b18224658d5d4b406c952c64d.zip | |
Document read_line gotcha
Diffstat (limited to 'library/std/src')
| -rw-r--r-- | library/std/src/io/mod.rs | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/library/std/src/io/mod.rs b/library/std/src/io/mod.rs index 23a13523fc2..3f940279bf2 100644 --- a/library/std/src/io/mod.rs +++ b/library/std/src/io/mod.rs @@ -2137,8 +2137,10 @@ pub trait BufRead: Read { } /// Read all bytes until a newline (the `0xA` byte) is reached, and append - /// them to the provided buffer. You do not need to clear the buffer before - /// appending. + /// them to the provided `String` buffer. + /// + /// Previous content of the buffer will be preserved. To avoid appending to + /// the buffer, you need to [`clear`] it first. /// /// This function will read bytes from the underlying stream until the /// newline delimiter (the `0xA` byte) or EOF is found. Once found, all bytes @@ -2154,6 +2156,7 @@ pub trait BufRead: Read { /// or EOF. /// /// [`Ok(0)`]: Ok + /// [`clear`]: String:::clear /// /// # Errors /// |
