Get the correct impl type

Hello,

I am fighting with rust analyzer:

struct B<T> {
    val: T,
}
struct C<T> {
    val: T,
}
pub trait ToB {
    type Type: ToB;
    fn to_b(self) -> B<Self::Type>;
}

impl ToB for f32 {
    type Type = f32;
    fn to_b(self) -> B<Self::Type> {
        B { val: self }
    }
}

impl ToB for C<f32> {
    type Type = f32;
    fn to_b(self) -> B<Self::Type> {
        B { val: self.val }
    }
}

pub trait Custom {
    fn custom(self, c: impl ToB) -> Self
    where
        Self: Sized,
        Self: Copy;
}

impl Custom for f32 {
    fn custom(self, c: impl ToB) -> Self
    where
        Self: Sized,
    {
        let b = c.to_b();
        b //expected type `f32` found struct `B<<impl ToB as ToB>::Type>`
    }
}

I was expecting the result to be f32 automagically.

Am I missing something ?

Thank you in advance for your help.

You can do this Rust Playground

pub trait Custom {
    type Ret;
    fn custom(self, c: impl ToB<Type = Self>) -> Self::Ret
    where
        Self: Sized + Copy;
}

impl Custom for f32 {
    type Ret = Self;
    fn custom(self, c: impl ToB<Type = f32>) -> Self
    {
        let b = c.to_b();
        b.val
    }
}

Yes, but I am expecting c.to_b() to always return B<f32>.
In next case, it returns B<C<f32>> instead of B<f32>:

impl Custom for C<f32> {
    type Ret = Self;
    //fn custom(self, c: impl ToB<Type = f32>) -> Self => failed ...
    fn custom(self, c: impl ToB<Type = C<f32>>) -> Self
    where
        Self: Sized,
    {
        let b = c.to_b();
        C { val: b.val }
    }
}
pub trait Custom {
    type Ret;
    fn custom(self, c: impl ToB<Type = f32>) -> Self::Ret;
}

impl Custom for C<f32> {
    type Ret = B<f32>;
    fn custom(self, c: impl ToB<Type = f32>) -> B<f32>
    {
        let b = c.to_b();
        b
    }
}

Rust Playground

Perfect !
Thank you very much, but I was hoping rust analyzer could guess the expected type instead of showing B<<impl ToB as ToB>::Type> and be able to use any type...