I don't think you get the point. You have already run the code. Therefore, you can also tell me what the error is. That saves me the effort to open an editor, paste in the code, compile it and then run it.
Here's a playground to a version that compiles: Rust Playground.
For the Err(month) case, month was bound to a ParseIntError (like previously pointed out by @MichaelV). but you were using it in a match that had patterns expecting a &str.
Err(month) =>
match month {
"january" => ...
The next error was that the original match was not exhaustive. There were cases for Ok(num) for a range of num as well as Err(..) but needed a case for Ok(num) when num did not fall into that range.
To fix that, I included the third case with the Error case:
Ok(_) | Err(_) =>
This will match a successful parse that fails the guard you have set up in the other case (num <= 12 && num > 0 and it will also match a parse error.
Side-note: Learn to (read and) post the whole warning/error message. The full warning in this case is
warning: value assigned to `birthmonth` is never read
--> src/lib.rs:5:11
|
5 | let mut birthmonth: u32 = 0;
| ^^^^^^^^^^
|
= note: `#[warn(unused_assignments)]` on by default
= help: maybe it is overwritten before being read?
The first line that you were missing is the most important one, as it's the main part of the warning message.
If your IDE doesn't show you the warning properly, take it from the terminal as returned by cargo check.
Resolving this warning can be done by removing the = 0 part assigning the unused initial value.
let mut birthmonth: u32;
In consequence, the mut might become redundant, too.
Another possible alternative is to use a break with value, and do
let birthmonth: u32 = loop {
....
break user_birthmonth;
};