<p>Hello,</p>

<p>While trying operator overloading in Rust, I see some unexepected behaviour of Geany. For a structure called ComplexNumber, the implementation of Add and Mul require separate implementation blocks. I expected that Add and Mul would be listed together with print and magnitude. If I try operator overloading in a similar way in C++, the member functions get nicely grouped below the name of the structure, even if they are defined in separate blocks. See the picture and the attached Rust example.</p>

<p><a href="https://cloud.githubusercontent.com/assets/7198614/10871318/e51a5f5a-80e3-11e5-987f-4e2fc4c16615.png" target="_blank"><img src="https://cloud.githubusercontent.com/assets/7198614/10871318/e51a5f5a-80e3-11e5-987f-4e2fc4c16615.png" alt="implementationsrust" style="max-width:100%;"></a></p>

<p>use std::ops::{Add,Mul};</p>

<p>#[derive(Debug,Copy,Clone)]<br>
pub struct ComplexNumber {<br>
    r : f64,<br>
    j : f64<br>
}</p>

<p>impl Add for ComplexNumber{<br>
    type Output = ComplexNumber;</p>

<pre><code>fn add(self, rhs: ComplexNumber) -> ComplexNumber {
    ComplexNumber {r: self.r+rhs.r, j: self.j+rhs.j}
}
</code></pre>

<p>}</p>

<p>impl Mul for ComplexNumber{<br>
    type Output = ComplexNumber;</p>

<pre><code>fn mul(self, rhs: ComplexNumber) -> ComplexNumber {
    ComplexNumber {r: self.r*rhs.r-self.j*rhs.j, j: self.r*rhs.j+self.j*rhs.r}
}
</code></pre>

<p>}</p>

<p>impl ComplexNumber {<br>
    fn print(& self) {<br>
        print!("{}+{}i ",self.r,self.j);<br>
    }<br>
    fn magnitude(& self) -> f64 {<br>
        (self.r.powi(2)+self.j.powi(2)).sqrt()<br>
    }<br>
}</p>

<p>fn main()<br>
{<br>
    let a = ComplexNumber {r: 1.0, j: 0.0};<br>
    let b = ComplexNumber {r: 0.0, j: 1.0};<br>
    let c = a + b;<br>
    let d = a * b;<br>
    let e = c + d;<br>
    c.print();<br>
    d.print();<br>
    e.print();<br>
    print!("{} ", e.magnitude());<br>
}</p>

<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">—<br>Reply to this email directly or <a href="https://github.com/geany/geany/issues/728">view it on GitHub</a>.<img alt="" height="1" src="https://github.com/notifications/beacon/ABDrJzWt85T0esawf2mFPOxIfPPYosfZks5pBnffgaJpZM4GZwvq.gif" width="1" /></p>
<div itemscope itemtype="http://schema.org/EmailMessage">
<div itemprop="action" itemscope itemtype="http://schema.org/ViewAction">
  <link itemprop="url" href="https://github.com/geany/geany/issues/728"></link>
  <meta itemprop="name" content="View Issue"></meta>
</div>
<meta itemprop="description" content="View this Issue on GitHub"></meta>
</div>