Rollup merge of #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.
This commit is contained in:
Matthias Krüger 2024-10-12 23:00:57 +02:00 committed by GitHub
commit c0f16828a1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -370,7 +370,12 @@ pub fn lock(&self) -> StdinLock<'static> {
/// 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
///