title: How do I implement the Add trait for a reference to a struct?
body: <p>I made a two element <code>Vector</code> struct and I want to overload the <code>+</code> operator.</p>
  
  <p>I made all my functions and methods take references, rather than values, and I want the <code>+</code> operator to work the same way.</p>
  
  <pre><code>impl Add for Vector {
      fn add(&amp;self, other: &amp;Vector) -&gt; Vector {
          Vector {
              x: self.x + other.x,
              y: self.y + other.y,
          }
      }
  }
  </code></pre>
  
  <p>Depending on which variation I try, I either get lifetime problems or type mismatches. Specifically, the <code>&amp;self</code> argument seems to not get treated as the right type.</p>
  
  <p>I have seen examples with template arguments on <code>impl</code> as well as <code>Add</code>, but they just result in different errors.</p>
  
  <p>I found <a href="https://stackoverflow.com/questions/24594374/overload-operators-with-different-rhs-type">How can an operator be overloaded for different RHS types and return values?</a> but the code in the answer doesn't work even if I put a <code>use std::ops::Mul;</code> at the top.</p>
  
  <p>I am using rustc 1.0.0-nightly (ed530d7a3 2015-01-16 22:41:16 +0000)</p>
  
  <p>I won't accept "you only have two fields, why use a reference" as an answer; what if I wanted a 100 element struct? I will accept an answer that demonstrates that even with a large struct I should be passing by value, if that is the case (I don't think it is, though.) I am interested in knowing a good rule of thumb for struct size and passing by value vs struct, but that is not the current question.</p>