diff --git a/common/src/format.rs b/common/src/format.rs index f9cf05e95..8e70cedb0 100644 --- a/common/src/format.rs +++ b/common/src/format.rs @@ -137,6 +137,28 @@ pub enum FormatType { Percentage, } +impl From<&FormatType> for char { + fn from(from: &FormatType) -> char { + match from { + FormatType::String => 's', + FormatType::Binary => 'b', + FormatType::Character => 'c', + FormatType::Decimal => 'd', + FormatType::Octal => 'o', + FormatType::HexLower => 'x', + FormatType::HexUpper => 'X', + FormatType::Number => 'n', + FormatType::ExponentLower => 'e', + FormatType::ExponentUpper => 'E', + FormatType::GeneralFormatLower => 'g', + FormatType::GeneralFormatUpper => 'G', + FormatType::FixedPointLower => 'f', + FormatType::FixedPointUpper => 'F', + FormatType::Percentage => '%', + } + } +} + impl FormatParse for FormatType { fn parse(text: &str) -> (Option, &str) { let mut chars = text.chars();