I copy pasted the code from The Rust Programming Language under the heading "Processing a Guess" onto the Rust Playground. However, there is no prompt shown in the standard output. I have searched for this problem and I think that this may be one of the "limitations" that the help lists.
I have decided that I should use some software that will help me code without the Playground, but I do not have an IDE set up yet, and that is not part of my question anyhow.
What I have tried to do is copy paste the following code onto the Rust playground:
use std::io;
fn main() {
println!("Guess the number!");
println!("Please input your guess.");
let mut guess = String::new();
io::stdin().read_line(&mut guess)
.expect("Failed to read line");
println!("You guessed: {}", guess);
}
The result is that it will compile properly without any panic attacks, errors, or warnings, and print to the 'standard output' the following:
Guess the number!
Please input your guess.
You guessed:
The information in Listing 2-1 in the book tells us that this code should be able to get a guess from the user and the print that guess (as a string).
My expectation is that I would be able to click on the line in the 'standard output' where it says:
You guessed:
but when I click on the white-space to the right of the colon, and start typing, no new string appears.
Am I missing something crucial here?
The Playground does not currently accept user input via stdin. The stdin is effectively closed immediately, thus your program gets no input and moves on to the next line of code, printing the "guess", which is just the empty string.
that this may be one of the "limitations" that the help lists.
It is not, but probably should be.
Source: I am the creator of the playground.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With