rust match 的问题0001


https://rust.cc/article?id=143b7d22-f7d7-48cf-a945-3b0b5f22c360

抱歉啊,还是没有明白,我把问题再简化一下啊:

 #[test] 
 fn test_result_0003(){
      use std::num::ParseIntError; 
      let my_result : Result<i32, ParseIntError> ; 
      let number_str = "10"; 
      my_result = number_str.parse::(); 
      // type_of 是自定义的 std::any::type_name 函数 
      // println!("type is:{}", type_of(my_result)); 
      // type is : core::result::Result<i32, core::num::ParseIntError>
      //问题: 既然 my_result 是 Result 类型,为什么match还是会有这个错误呢 // 

 let number = match my_result { 
      Ok(number) => number, 
      Err(e) => e , //^ expected i32, found struct std::num::ParseIntError 
     }; 
     println!("{}", number); 
 }

我的问题:

1)my_result 的类型是( 运行时的类型 ):
type is : core::result::Result<i32, core::num::ParseIntError>

2)那么 match my_result 在编译的时候,为什么还是提示:

    Err(e) => e , //^ expected i32, found struct std::num::ParseIntError  

    match 匹配 Result 应该说:<T,E> , T和E 只要一个符合就可以吧.