mirror of
https://github.com/RustPython/RustPython.git
synced 2026-10-28 18:59:04 +08:00
Implement From trait
This commit is contained in:
1 parent
478aa41cc6
commit
e11cda970a
1 file changed
+22
@@ -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<Self>, &str) {
|
||||
let mut chars = text.chars();
|
||||
|
||||
Reference in new issue
Block a user