use std::fmt;
use std::ops::Add;
#[derive(Debug, PartialEq)]
pub struct Complex(pub u64, pub u64);
impl fmt::Display for Complex {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "({}, {}i)", self.0, self.1)
}
}
impl Add for Complex {
type Output = Self;
fn add(self, other: Self) -> Self {
Self(
self.0 + other.0,
self.1 + other.1,
)
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn it_works() {
let result = 2 + 2;
assert_eq!(result, 4);
}
#[test]
fn add_works() {
assert_eq!(Complex(1, 2) + Complex(3, 4), Complex(4, 6));
}
}