File tree Expand file tree Collapse file tree
modules/openapi-generator/src/main/resources/rust
api-with-ref-param/src/models
api-with-ref-param/src/models
hyper/petstore/src/models
petstore-async-middleware/src/models
petstore-async/src/models
petstore-avoid-box/src/models
petstore-awsv4signature/src/models Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -21,12 +21,12 @@ pub enum {{{classname}}} {
2121{ {/enumVars} }{ {/allowableValues} }
2222}
2323
24- impl ToString for { {{classname} }} {
25- fn to_string (&self) -> String {
24+ impl std::fmt::Display for { {{classname} }} {
25+ fn fmt (&self, f: &mut std::fmt::Formatter ) -> std::fmt::Result {
2626 match self {
2727 {{#allowableValues} }
2828 { {#enumVars} }
29- Self::{ {{name} }} => String::from( "{ {{value} }}"),
29+ Self::{ {{name} }} => write!(f, "{ {{value} }}"),
3030 { {/enumVars} }
3131 { {/allowableValues} }
3232 }
Original file line number Diff line number Diff line change @@ -23,12 +23,12 @@ pub enum Color {
2323
2424}
2525
26- impl ToString for Color {
27- fn to_string ( & self ) -> String {
26+ impl std :: fmt :: Display for Color {
27+ fn fmt ( & self , f : & mut std :: fmt :: Formatter ) -> std :: fmt :: Result {
2828 match self {
29- Self :: Red => String :: from ( "RED" ) ,
30- Self :: Green => String :: from ( "GREEN" ) ,
31- Self :: Blue => String :: from ( "BLUE" ) ,
29+ Self :: Red => write ! ( f , "RED" ) ,
30+ Self :: Green => write ! ( f , "GREEN" ) ,
31+ Self :: Blue => write ! ( f , "BLUE" ) ,
3232 }
3333 }
3434}
Original file line number Diff line number Diff line change @@ -21,11 +21,11 @@ pub enum FruitType {
2121
2222}
2323
24- impl ToString for FruitType {
25- fn to_string ( & self ) -> String {
24+ impl std :: fmt :: Display for FruitType {
25+ fn fmt ( & self , f : & mut std :: fmt :: Formatter ) -> std :: fmt :: Result {
2626 match self {
27- Self :: Apple => String :: from ( "APPLE" ) ,
28- Self :: Banana => String :: from ( "BANANA" ) ,
27+ Self :: Apple => write ! ( f , "APPLE" ) ,
28+ Self :: Banana => write ! ( f , "BANANA" ) ,
2929 }
3030 }
3131}
Original file line number Diff line number Diff line change @@ -23,12 +23,12 @@ pub enum Color {
2323
2424}
2525
26- impl ToString for Color {
27- fn to_string ( & self ) -> String {
26+ impl std :: fmt :: Display for Color {
27+ fn fmt ( & self , f : & mut std :: fmt :: Formatter ) -> std :: fmt :: Result {
2828 match self {
29- Self :: Red => String :: from ( "RED" ) ,
30- Self :: Green => String :: from ( "GREEN" ) ,
31- Self :: Blue => String :: from ( "BLUE" ) ,
29+ Self :: Red => write ! ( f , "RED" ) ,
30+ Self :: Green => write ! ( f , "GREEN" ) ,
31+ Self :: Blue => write ! ( f , "BLUE" ) ,
3232 }
3333 }
3434}
Original file line number Diff line number Diff line change @@ -21,11 +21,11 @@ pub enum FruitType {
2121
2222}
2323
24- impl ToString for FruitType {
25- fn to_string ( & self ) -> String {
24+ impl std :: fmt :: Display for FruitType {
25+ fn fmt ( & self , f : & mut std :: fmt :: Formatter ) -> std :: fmt :: Result {
2626 match self {
27- Self :: Apple => String :: from ( "APPLE" ) ,
28- Self :: Banana => String :: from ( "BANANA" ) ,
27+ Self :: Apple => write ! ( f , "APPLE" ) ,
28+ Self :: Banana => write ! ( f , "BANANA" ) ,
2929 }
3030 }
3131}
Original file line number Diff line number Diff line change @@ -24,12 +24,12 @@ pub enum Baz {
2424
2525}
2626
27- impl ToString for Baz {
28- fn to_string ( & self ) -> String {
27+ impl std :: fmt :: Display for Baz {
28+ fn fmt ( & self , f : & mut std :: fmt :: Formatter ) -> std :: fmt :: Result {
2929 match self {
30- Self :: A => String :: from ( "A" ) ,
31- Self :: B => String :: from ( "B" ) ,
32- Self :: Empty => String :: from ( "" ) ,
30+ Self :: A => write ! ( f , "A" ) ,
31+ Self :: B => write ! ( f , "B" ) ,
32+ Self :: Empty => write ! ( f , "" ) ,
3333 }
3434 }
3535}
Original file line number Diff line number Diff line change @@ -24,12 +24,12 @@ pub enum Baz {
2424
2525}
2626
27- impl ToString for Baz {
28- fn to_string ( & self ) -> String {
27+ impl std :: fmt :: Display for Baz {
28+ fn fmt ( & self , f : & mut std :: fmt :: Formatter ) -> std :: fmt :: Result {
2929 match self {
30- Self :: A => String :: from ( "A" ) ,
31- Self :: B => String :: from ( "B" ) ,
32- Self :: Empty => String :: from ( "" ) ,
30+ Self :: A => write ! ( f , "A" ) ,
31+ Self :: B => write ! ( f , "B" ) ,
32+ Self :: Empty => write ! ( f , "" ) ,
3333 }
3434 }
3535}
Original file line number Diff line number Diff line change @@ -24,12 +24,12 @@ pub enum Baz {
2424
2525}
2626
27- impl ToString for Baz {
28- fn to_string ( & self ) -> String {
27+ impl std :: fmt :: Display for Baz {
28+ fn fmt ( & self , f : & mut std :: fmt :: Formatter ) -> std :: fmt :: Result {
2929 match self {
30- Self :: A => String :: from ( "A" ) ,
31- Self :: B => String :: from ( "B" ) ,
32- Self :: Empty => String :: from ( "" ) ,
30+ Self :: A => write ! ( f , "A" ) ,
31+ Self :: B => write ! ( f , "B" ) ,
32+ Self :: Empty => write ! ( f , "" ) ,
3333 }
3434 }
3535}
Original file line number Diff line number Diff line change @@ -24,12 +24,12 @@ pub enum Baz {
2424
2525}
2626
27- impl ToString for Baz {
28- fn to_string ( & self ) -> String {
27+ impl std :: fmt :: Display for Baz {
28+ fn fmt ( & self , f : & mut std :: fmt :: Formatter ) -> std :: fmt :: Result {
2929 match self {
30- Self :: A => String :: from ( "A" ) ,
31- Self :: B => String :: from ( "B" ) ,
32- Self :: Empty => String :: from ( "" ) ,
30+ Self :: A => write ! ( f , "A" ) ,
31+ Self :: B => write ! ( f , "B" ) ,
32+ Self :: Empty => write ! ( f , "" ) ,
3333 }
3434 }
3535}
Original file line number Diff line number Diff line change @@ -24,12 +24,12 @@ pub enum Baz {
2424
2525}
2626
27- impl ToString for Baz {
28- fn to_string ( & self ) -> String {
27+ impl std :: fmt :: Display for Baz {
28+ fn fmt ( & self , f : & mut std :: fmt :: Formatter ) -> std :: fmt :: Result {
2929 match self {
30- Self :: A => String :: from ( "A" ) ,
31- Self :: B => String :: from ( "B" ) ,
32- Self :: Empty => String :: from ( "" ) ,
30+ Self :: A => write ! ( f , "A" ) ,
31+ Self :: B => write ! ( f , "B" ) ,
32+ Self :: Empty => write ! ( f , "" ) ,
3333 }
3434 }
3535}
You can’t perform that action at this time.
0 commit comments