(&self, default_format_type: FormatType)
| 412 | } |
| 413 | |
| 414 | fn validate_format(&self, default_format_type: FormatType) -> Result<(), FormatSpecError> { |
| 415 | let format_type = self.format_type.as_ref().unwrap_or(&default_format_type); |
| 416 | match (&self.grouping_option, format_type) { |
| 417 | ( |
| 418 | Some(FormatGrouping::Comma), |
| 419 | FormatType::String |
| 420 | | FormatType::Character |
| 421 | | FormatType::Binary |
| 422 | | FormatType::Octal |
| 423 | | FormatType::Hex(_) |
| 424 | | FormatType::Number(_), |
| 425 | ) => { |
| 426 | let ch = char::from(format_type); |
| 427 | Err(FormatSpecError::UnspecifiedFormat(',', ch)) |
| 428 | } |
| 429 | ( |
| 430 | Some(FormatGrouping::Underscore), |
| 431 | FormatType::String | FormatType::Character | FormatType::Number(_), |
| 432 | ) => { |
| 433 | let ch = char::from(format_type); |
| 434 | Err(FormatSpecError::UnspecifiedFormat('_', ch)) |
| 435 | } |
| 436 | _ => Ok(()), |
| 437 | } |
| 438 | } |
| 439 | |
| 440 | const fn get_separator_interval(&self) -> usize { |
| 441 | match self.format_type { |
no test coverage detected