Strange ParseIntError { kind: Empty }

I'm new to Rust, and I'm writing a small temperature converter. Get the error "Enter a number!: ParseIntError { kind: Empty }" when entering data. Here is the piece of code in question:

 let mut typo = String::new();
 let mut degrees = String::new();

 println!("Enter degrees: ");

 io::stdin()
     .read_line(&mut degrees).expect("Failed to read line");

 let degrees: i16 = typo.trim().parse().expect("Enter a number!");

Idk why compiler say that input is empty when it's not, thanks for any help.

You're reading the input into degrees but you're parsing typo.

4 Likes

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.