It doesn't work when i use shadowing

it work well:

let mut a = String::from("hello");
let a = a.len();
match a {
    1 => println!("1"),
    2 => println!("2"),
    _ => println!("other"),
}

but it doesn't work:

let mut number = String::new();
io::stdin().read_line(&mut number).expect("cannot get your write number.");

let numer: i32 = number.trim().parse().expect("invalid number");
match number {
    1 => guess_number::game(),
    2 => test01::test01(),
    _ => {
        println!("mode number not support.")
    }
}

error is:

    Checking review v0.1.0 (D:\develop\rust\project\review)
error[E0308]: mismatched types
  --> src\main.rs:23:9
   |
22 |     match number {
   |           ------ this expression has type `String`
23 |         1 => guess_number::game(),
   |         ^ expected `String`, found integer

error[E0308]: mismatched types
  --> src\main.rs:24:9
   |
22 |     match number {
   |           ------ this expression has type `String`
23 |         1 => guess_number::game(),
24 |         2 => test01::test01(),
   |         ^ expected `String`, found integer

You just mispelled number. :slight_smile:

1 Like

thx!
oh my shit question...:sweat:

2 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.