MCPcopy Index your code
hub / github.com/RustPython/RustPython / validate_format

Method validate_format

crates/common/src/format.rs:414–438  ·  view source on GitHub ↗
(&self, default_format_type: FormatType)

Source from the content-addressed store, hash-verified

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 {

Callers 6

format_int_localeMethod · 0.80
format_float_localeMethod · 0.80
format_floatMethod · 0.80
format_intMethod · 0.80
format_stringMethod · 0.80
format_complex_floatMethod · 0.80

Calls 2

ErrClass · 0.50
as_refMethod · 0.45

Tested by

no test coverage detected