// some things are automatically loaded in every rust program
// https://doc.rust-lang.org/std/prelude/index.html
// for extras, import them with `use`:
use std::io;

fn main() {
    println!("Guess the number!");
    println!("input your guess");
    // vars are immutable by default, change this
    // The :: syntax in the ::new line indicates that new is an _associated function_ of the String
    //         a function that’s implemented on a type
    let mut guess = String::new();
    // could still call this without importing it via std::io::stdin
    // this can be one line, it is broken up for readability.
    io::stdin()
        // & indicates that this argument is a reference,
        // references are also immutable by default so &mut is needed
        .read_line(&mut guess)
        // expect handles the Err variant by crashing the program. There are other ways to handle
        // errors.
        .expect("Failed to read line");
    // read_line returns a `result` value. result is an enum. Each possible state is a variant.
    // Result's variants are Ok and Err

    println!("you guessed: {guess}");
}
