Hi, I am just new to Rust.
I am trying to implement a conversion between my custom struct Vec3
pub struct Vec3<T> (pub T, pub T, pub T);
basically I want a from/into trait that can conveniently convert between Vec3<f64>
and Vec3<f32>
, for example
Vec3(1.0f32, 2.0f32, 3.0f32).into()
will get something like
Vec3(1.0f64, 2.0f64, 3.0f64)
what I am doing now is
impl<U, T> From<Vec3<U>> for Vec3<T>
where
U: Into<T>,
T: Float,
{
fn from(value: Vec3<U>) > Vec3<T> {
Vec3(value.x().into(), value.y().into(), value.z().into())
}
}
However, I got the error
error[E0119]: conflicting implementations of trait `Into<_>` for type `vec3::Vec3<_>`
> src/vec3.rs:16:1

16  impl<T: Float, U: Float> Into<U> for Vec3<T>
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

= note: conflicting implementation in crate `core`:
 impl<T, U> Into<U> for T
where U: From<T>