(&self, num: &Complex64)
| 854 | } |
| 855 | |
| 856 | pub fn format_complex(&self, num: &Complex64) -> Result<String, FormatSpecError> { |
| 857 | let (formatted_re, formatted_im) = self.format_complex_re_im(num)?; |
| 858 | // Enclose in parentheses if there is no format type and formatted_re is not empty |
| 859 | let magnitude_str = if self.format_type.is_none() && !formatted_re.is_empty() { |
| 860 | format!("({formatted_re}{formatted_im})") |
| 861 | } else { |
| 862 | format!("{formatted_re}{formatted_im}") |
| 863 | }; |
| 864 | if let Some(FormatAlign::AfterSign) = &self.align { |
| 865 | return Err(FormatSpecError::AlignmentFlag); |
| 866 | } |
| 867 | match &self.fill.unwrap_or(' '.into()).to_char() { |
| 868 | Some('0') => Err(FormatSpecError::ZeroPadding), |
| 869 | _ => self.format_sign_and_align(&AsciiStr::new(&magnitude_str), "", FormatAlign::Right), |
| 870 | } |
| 871 | } |
| 872 | |
| 873 | fn format_complex_re_im(&self, num: &Complex64) -> Result<(String, String), FormatSpecError> { |
| 874 | // Format real part |
no test coverage detected