forked from loafle/openapi-generator-original
Use Display instead of ToString in Rust generators (#18633)
This commit is contained in:
parent
365fcd3fb4
commit
970424678e
@ -21,12 +21,12 @@ pub enum {{{classname}}} {
|
||||
{{/enumVars}}{{/allowableValues}}
|
||||
}
|
||||
|
||||
impl ToString for {{{classname}}} {
|
||||
fn to_string(&self) -> String {
|
||||
impl std::fmt::Display for {{{classname}}} {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
||||
match self {
|
||||
{{#allowableValues}}
|
||||
{{#enumVars}}
|
||||
Self::{{{name}}} => String::from("{{{value}}}"),
|
||||
Self::{{{name}}} => write!(f, "{{{value}}}"),
|
||||
{{/enumVars}}
|
||||
{{/allowableValues}}
|
||||
}
|
||||
|
@ -23,12 +23,12 @@ pub enum Color {
|
||||
|
||||
}
|
||||
|
||||
impl ToString for Color {
|
||||
fn to_string(&self) -> String {
|
||||
impl std::fmt::Display for Color {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
||||
match self {
|
||||
Self::Red => String::from("RED"),
|
||||
Self::Green => String::from("GREEN"),
|
||||
Self::Blue => String::from("BLUE"),
|
||||
Self::Red => write!(f, "RED"),
|
||||
Self::Green => write!(f, "GREEN"),
|
||||
Self::Blue => write!(f, "BLUE"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -21,11 +21,11 @@ pub enum FruitType {
|
||||
|
||||
}
|
||||
|
||||
impl ToString for FruitType {
|
||||
fn to_string(&self) -> String {
|
||||
impl std::fmt::Display for FruitType {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
||||
match self {
|
||||
Self::Apple => String::from("APPLE"),
|
||||
Self::Banana => String::from("BANANA"),
|
||||
Self::Apple => write!(f, "APPLE"),
|
||||
Self::Banana => write!(f, "BANANA"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -23,12 +23,12 @@ pub enum Color {
|
||||
|
||||
}
|
||||
|
||||
impl ToString for Color {
|
||||
fn to_string(&self) -> String {
|
||||
impl std::fmt::Display for Color {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
||||
match self {
|
||||
Self::Red => String::from("RED"),
|
||||
Self::Green => String::from("GREEN"),
|
||||
Self::Blue => String::from("BLUE"),
|
||||
Self::Red => write!(f, "RED"),
|
||||
Self::Green => write!(f, "GREEN"),
|
||||
Self::Blue => write!(f, "BLUE"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -21,11 +21,11 @@ pub enum FruitType {
|
||||
|
||||
}
|
||||
|
||||
impl ToString for FruitType {
|
||||
fn to_string(&self) -> String {
|
||||
impl std::fmt::Display for FruitType {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
||||
match self {
|
||||
Self::Apple => String::from("APPLE"),
|
||||
Self::Banana => String::from("BANANA"),
|
||||
Self::Apple => write!(f, "APPLE"),
|
||||
Self::Banana => write!(f, "BANANA"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -24,12 +24,12 @@ pub enum Baz {
|
||||
|
||||
}
|
||||
|
||||
impl ToString for Baz {
|
||||
fn to_string(&self) -> String {
|
||||
impl std::fmt::Display for Baz {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
||||
match self {
|
||||
Self::A => String::from("A"),
|
||||
Self::B => String::from("B"),
|
||||
Self::Empty => String::from(""),
|
||||
Self::A => write!(f, "A"),
|
||||
Self::B => write!(f, "B"),
|
||||
Self::Empty => write!(f, ""),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -24,12 +24,12 @@ pub enum Baz {
|
||||
|
||||
}
|
||||
|
||||
impl ToString for Baz {
|
||||
fn to_string(&self) -> String {
|
||||
impl std::fmt::Display for Baz {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
||||
match self {
|
||||
Self::A => String::from("A"),
|
||||
Self::B => String::from("B"),
|
||||
Self::Empty => String::from(""),
|
||||
Self::A => write!(f, "A"),
|
||||
Self::B => write!(f, "B"),
|
||||
Self::Empty => write!(f, ""),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -24,12 +24,12 @@ pub enum Baz {
|
||||
|
||||
}
|
||||
|
||||
impl ToString for Baz {
|
||||
fn to_string(&self) -> String {
|
||||
impl std::fmt::Display for Baz {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
||||
match self {
|
||||
Self::A => String::from("A"),
|
||||
Self::B => String::from("B"),
|
||||
Self::Empty => String::from(""),
|
||||
Self::A => write!(f, "A"),
|
||||
Self::B => write!(f, "B"),
|
||||
Self::Empty => write!(f, ""),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -24,12 +24,12 @@ pub enum Baz {
|
||||
|
||||
}
|
||||
|
||||
impl ToString for Baz {
|
||||
fn to_string(&self) -> String {
|
||||
impl std::fmt::Display for Baz {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
||||
match self {
|
||||
Self::A => String::from("A"),
|
||||
Self::B => String::from("B"),
|
||||
Self::Empty => String::from(""),
|
||||
Self::A => write!(f, "A"),
|
||||
Self::B => write!(f, "B"),
|
||||
Self::Empty => write!(f, ""),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -24,12 +24,12 @@ pub enum Baz {
|
||||
|
||||
}
|
||||
|
||||
impl ToString for Baz {
|
||||
fn to_string(&self) -> String {
|
||||
impl std::fmt::Display for Baz {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
||||
match self {
|
||||
Self::A => String::from("A"),
|
||||
Self::B => String::from("B"),
|
||||
Self::Empty => String::from(""),
|
||||
Self::A => write!(f, "A"),
|
||||
Self::B => write!(f, "B"),
|
||||
Self::Empty => write!(f, ""),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -24,12 +24,12 @@ pub enum Baz {
|
||||
|
||||
}
|
||||
|
||||
impl ToString for Baz {
|
||||
fn to_string(&self) -> String {
|
||||
impl std::fmt::Display for Baz {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
||||
match self {
|
||||
Self::A => String::from("A"),
|
||||
Self::B => String::from("B"),
|
||||
Self::Empty => String::from(""),
|
||||
Self::A => write!(f, "A"),
|
||||
Self::B => write!(f, "B"),
|
||||
Self::Empty => write!(f, ""),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user