How do I implement the Add trait for a reference to a struct?
You need to implement Add on &Vector rather than on Vector. impl<‘a, ‘b> Add<&’b Vector> for &’a Vector { type Output = Vector; fn add(self, other: &’b Vector) -> Vector { Vector { x: self.x + other.x, y: self.y + other.y, } } } In its definition, Add::add always takes self by value. But references … Read more