Using .into() when type inference is impossible

前端 未结 4 1321
情话喂你
情话喂你 2020-12-03 17:08

I\'m hoping to be able to use .into() to convert a value in a context where type inference is impossible. This is typically when I want to convert a temporary v

4条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-03 17:16

    You can simply annotate the type of the result by assigning it to a variable.

    let b: i32 = a.into();
    println!("{}", b);
    

提交回复
热议问题