easy_complex/
display.rs

1//! Generates the display of the given struct
2
3macro_rules! gen_display {
4	(Complex, [ $($float:ty),+ ]) => (
5		$(
6		impl common::fmt::Display for Complex<$float> {
7			fn fmt(&self, f: &mut common::fmt::Formatter) -> common::fmt::Result {
8				write!(f, "{} {} {}j", self.real, if self.imag.is_sign_positive() {"+"} else {"-"}, self.imag)
9			}
10		}
11		)+
12	);
13
14	(EComplex, [ $($float:ty),+ ]) => (
15		$(
16		impl common::fmt::Display for EComplex<$float> {
17			fn fmt(&self, f: &mut common::fmt::Formatter) -> common::fmt::Result {
18				write!(f, "{} ยท e^({}j)", self.module, self.arg)
19			}
20		}
21		)+
22	);
23}