I have a custom type Point
type Point = (f64, f64);
And I want to add two Point
s together but I get this error
error[E0368]: binary assignment operation `+=` cannot be applied to type `(f64, f64)`
--> src/main.rs:119:21
|
119 | force_map[&body.name] += force;
| ---------------------^^^^^^^^^
| |
| cannot use `+=` on type `(f64, f64)`
And when I try implementing Add, I get this error:
39 | / impl Add for (f64, f64) {
40 | | #[inline(always)]
41 | | fn add(self, other: (f64, f64)) -> (f64, f64) {
42 | | // Probably it will be optimized to not actually copy self and rhs for each call !
43 | | (self.0 + other.0, self.1 + other.1);
44 | | }
45 | | }
| |_^ impl doesn't use types inside crate
|
= note: the impl does not reference any types defined in this crate
= note: define and implement a trait or new type instead
Is it possible to implement Add
for a type
? Should I use a struct
instead?