Question: How would I solve the following problem? ## Operator overloading A common use of traits is to [overload operators](https://doc.rust-lang.org/book/operators-and-overloading.html). This is an example of polymorphism
How would I solve the following problem? ## Operator overloading A common use of traits is to [overload operators](https://doc.rust-lang.org/book/operators-and-overloading.html). This is an example of polymorphism in object-oriented paradigm. It allows you define existing operators on your custom types. ## Example The following program overloads the `+`, `-`, and `*` operators and implements the `Display` trait on the `Complex` type. ``` use std::{ops, fmt}; #[derive(PartialEq, Debug)] pub struct Complex { re: T, im: T, } impl> ops::Add for Complex { type Output = Self; fn add(self, rhs: Self) -> Self::Output { Complex { re: self.re + rhs.re, im: self.im + rhs.im, } } } impl> ops::Sub for Complex { type Output = Self; fn sub(self, rhs: Self) -> Self::Output { Complex { re: self.re - rhs.re, im: self.im - rhs.im, } } } impl + ops::Sub