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:
Tim (Theemathas) Chirananthavat 2024-10-10 23:12:03 +07:00
parent 4cc494bbfe
commit 203573701a

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. /// 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 /// 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 /// # Examples
/// ///