RUST Read single line from stdinIn Rust 0.4, use the ReaderUtil trait to access the read_line function. Note that you need to explicitly cast the value to a trait type, for example, reader as io::ReaderUtil:
RUST Example of taking input from user
Manually iterate without a for-loop
You cannot write a one-liner to do what you want. But the following reads a single line.
You can also use the text_io crate for super simple input:
Example using text_io
In this page (written and validated by A. Gawali) you learned about Rust Read single line from stdin . What's Next? If you are interested in completing Rust tutorial, your next topic will be learning about: Rust Data Types.
Incorrect info or code snippet? We take very seriously the accuracy of the information provided on our website. We also make sure to test all snippets and examples provided for each section. If you find any incorrect information, please send us an email about the issue: email@example.com.