E0283 type annotations required

Hi guys, can anyone explain me why the following code is not compiling and how I can fixed?
The error I got is

error[E0283]: type annotations required: cannot resolve `Ts: std::convert::Into<_>`
pub struct Ts;

impl Ts{
    fn new()->Ts{

impl Into<f64> for Ts {
    fn into(self) -> f64 {

fn main(){
    let ts:Ts = Ts::new();

You can see the code on the rust playground:


Thank you very much for your time!

Rust does not know which type you want to convert Ts to. Try let v: f64 = ts.into();.

You may think it’s obvious there’s only one option, but there is also a default into implementation in the std, so the compiler sees multiple possible conversions and wants you to specify which one you want.

1 Like

I got it,
thank you very much guys

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.