Let's dig in!
The first line use std::io
brings the standard io (input/output) library into scope. We've covered main
and println!
, so let's go into let
, mut
, and String::new
. let
is used to defined variables, like so:
A standard variable is immutable (cannot be changed), but mut
makes it mutable.
Here's the error message you will see if you try to change an immutable variable.
Rust also binds variables to a certain type when they are initialized. For example, with line :
guess
is bound to an empty string. Here's an example of how this works:
Last updated