Design of `std::stdin()`

⚓ Rust    📅 2025-12-25    👤 surdeus    👁️ 1      

surdeus

Info

This post is auto-generated from RSS feed The Rust Programming Language Forum - Latest topics. Source: Design of `std::stdin()`

The docs for std::io have a basic code to capture input:

let guess = String::new(); 
io::stdin().read_line(&mut guess)

But why wouldn't there be something like:

let guess = io::stdin().read_line()

which returns a String ? I assume there is a good reason since otherwise it'd be unnecessarily made harder.

3 posts - 3 participants

Read full topic

🏷️ Rust_feed