Hello,
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.
![implementationsrust](https://cloud.githubusercontent.com/assets/7198614/10871318/e51a5f5a-80e3-11...)
use std::ops::{Add,Mul};
#[derive(Debug,Copy,Clone)] pub struct ComplexNumber { r : f64, j : f64 }
impl Add for ComplexNumber{ type Output = ComplexNumber;
fn add(self, rhs: ComplexNumber) -> ComplexNumber { ComplexNumber {r: self.r+rhs.r, j: self.j+rhs.j} }
}
impl Mul for ComplexNumber{ type Output = ComplexNumber;
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} }
}
impl ComplexNumber { fn print(& self) { print!("{}+{}i ",self.r,self.j); } fn magnitude(& self) -> f64 { (self.r.powi(2)+self.j.powi(2)).sqrt() } }
fn main() { let a = ComplexNumber {r: 1.0, j: 0.0}; let b = ComplexNumber {r: 0.0, j: 1.0}; let c = a + b; let d = a * b; let e = c + d; c.print(); d.print(); e.print(); print!("{} ", e.magnitude()); }
--- Reply to this email directly or view it on GitHub: https://github.com/geany/geany/issues/728