+ 3
Rust string error
// first question println!("what CPU stand for?"); let mut first_answer: String = String::new(); io::stdin() .read_line(&mut first_answer) .expect("Something went wrong"); let first_answer = first_answer.trim_end(); // Check if the answer from first question correct or not match first_answer.to_lowercase() { "central processing unit" => { println!("Congratulations you're Correct. Good job đ"); println!("next question.."); }, _ => println!("Unfortunately you're incorrect"), }; Error message: expected struct `String`, found `&str`
5 Answers
+ 1
match first_answer.to_lowercase().as_str() {
...
}
+ 1
"central processing unit" is of type &str but first_answer.to_lowercase() returns String and you are trying to compare both
0
Actually already solved it with if else startment in rust
0
One more question
0
Why when i use if else startment doesn't get any error and when i use match i am getting an error