stdinlock
StdinLock is a locked, borrowing handle to the standard input provided by Rust’s standard library. It is produced by calling the lock method on a Stdin handle (for example, std::io::stdin().lock()) and represents exclusive access to standard input for the duration of the lock. The type is std::io::StdinLock<'a>, where 'a is the lifetime of the borrowed Stdin.
StdinLock implements the Read and BufRead traits, enabling both byte-wise and line-oriented input operations. This includes
The lock is released automatically when the StdinLock value goes out of scope (or is dropped), returning
Usage typically involves obtaining a lock once and reusing it for subsequent reads within the scope. For
lock.read_line(&mut line).unwrap();
StdinLock is a lightweight, ephemeral guard around the global standard input. It is designed for simplicity