hello! i'm trying to implement my own vector3 type, but i can't get multiplication with a number to work. my code (MRE) looks like this:
#[derive(Eq, PartialEq, Debug, Copy, Clone)]
pub struct Vec3<T> {
pub x: T,
pub y: T,
pub z: T,
}
impl<T: Mul<Output = T>> Mul for T {
type Output = Vec3<T>;
fn mul(self, rhs: Vec3<T>) -> Self::Output {
Self {
x: self.x * rhs,
y: self.y * rhs,
z: self.z * rhs,
}
}
}
the error states the following:
error[E0275]: overflow evaluating the requirement `u32: Mul`
|
= help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`glass`)
note: required for `u32` to implement `Mul`
--> src/math/vec.rs:34:26
|
34 | impl<T: Mul<Output = T>> Mul for T {
| ---------- ^^^ ^
| |
| unsatisfied trait bound introduced here
= note: 126 redundant requirements hidden
= note: required for `u32` to implement `Mul`
For more information about this error, try `rustc --explain E0275`.
does anyone have any idea how to fix it? i tried the recursion limit thing, but it just increases the number in the error everytime I set it to it.