How to use std::convert::Into in statements in Rust? [duplicate]
问题 This question already has answers here : Using .into() when type inference is impossible (4 answers) Closed last year . I am trying to use into in the following code this way: use std::convert::{From, Into}; struct MyStruct { x: i64, } impl From<i64> for MyStruct { fn from(a: i64) -> Self { Self { x: a } } } impl Into<i64> for MyStruct { fn into(self) -> i64 { self.x } } fn main() { let s = MyStruct::from(5); let b = s.into() == 5; println!("{:?}", b); } It produces an error: error[E0283]: