X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=library%2Fstd%2Fsrc%2Fio%2Fmod.rs;h=de528e85368cbf5ed6b471b7411f4e3b97b53ca4;hb=782da867c801441212a00f20bf75bc312c815460;hp=23a13523fc275be62e588a04935d0ffa12f51d6f;hpb=3278dea67afec3b25c5fe42c6b2171f1524adc4c;p=rust.git diff --git a/library/std/src/io/mod.rs b/library/std/src/io/mod.rs index 23a13523fc2..de528e85368 100644 --- a/library/std/src/io/mod.rs +++ b/library/std/src/io/mod.rs @@ -2137,8 +2137,10 @@ fn read_until(&mut self, byte: u8, buf: &mut Vec) -> Result { } /// 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 @@ -2151,9 +2153,11 @@ fn read_until(&mut self, byte: u8, buf: &mut Vec) -> Result { /// /// This function is blocking and should be used carefully: it is possible for /// an attacker to continuously send bytes without ever sending a newline - /// or EOF. + /// or EOF. You can use [`take`] to limit the maximum number of bytes read. /// /// [`Ok(0)`]: Ok + /// [`clear`]: String::clear + /// [`take`]: crate::io::Read::take /// /// # Errors ///