File tree Expand file tree Collapse file tree 11 files changed +51
-51
lines changed
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/src/models
petstore-async-middleware/src/models
petstore-avoid-box/src/models
petstore-awsv4signature/src/models Expand file tree Collapse file tree 11 files changed +51
-51
lines changed Original file line number Diff line number Diff line change @@ -21,12 +21,12 @@ pub enum {{{classname}}} {
21
21
{ {/enumVars} }{ {/allowableValues} }
22
22
}
23
23
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 {
26
26
match self {
27
27
{{#allowableValues} }
28
28
{ {#enumVars} }
29
- Self::{ {{name} }} => String::from( "{ {{value} }}"),
29
+ Self::{ {{name} }} => write!(f, "{ {{value} }}"),
30
30
{ {/enumVars} }
31
31
{ {/allowableValues} }
32
32
}
Original file line number Diff line number Diff line change @@ -23,12 +23,12 @@ pub enum Color {
23
23
24
24
}
25
25
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 {
28
28
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" ) ,
32
32
}
33
33
}
34
34
}
Original file line number Diff line number Diff line change @@ -21,11 +21,11 @@ pub enum FruitType {
21
21
22
22
}
23
23
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 {
26
26
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" ) ,
29
29
}
30
30
}
31
31
}
Original file line number Diff line number Diff line change @@ -23,12 +23,12 @@ pub enum Color {
23
23
24
24
}
25
25
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 {
28
28
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" ) ,
32
32
}
33
33
}
34
34
}
Original file line number Diff line number Diff line change @@ -21,11 +21,11 @@ pub enum FruitType {
21
21
22
22
}
23
23
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 {
26
26
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" ) ,
29
29
}
30
30
}
31
31
}
Original file line number Diff line number Diff line change @@ -24,12 +24,12 @@ pub enum Baz {
24
24
25
25
}
26
26
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 {
29
29
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 , "" ) ,
33
33
}
34
34
}
35
35
}
Original file line number Diff line number Diff line change @@ -24,12 +24,12 @@ pub enum Baz {
24
24
25
25
}
26
26
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 {
29
29
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 , "" ) ,
33
33
}
34
34
}
35
35
}
Original file line number Diff line number Diff line change @@ -24,12 +24,12 @@ pub enum Baz {
24
24
25
25
}
26
26
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 {
29
29
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 , "" ) ,
33
33
}
34
34
}
35
35
}
Original file line number Diff line number Diff line change @@ -24,12 +24,12 @@ pub enum Baz {
24
24
25
25
}
26
26
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 {
29
29
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 , "" ) ,
33
33
}
34
34
}
35
35
}
Original file line number Diff line number Diff line change @@ -24,12 +24,12 @@ pub enum Baz {
24
24
25
25
}
26
26
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 {
29
29
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 , "" ) ,
33
33
}
34
34
}
35
35
}
Original file line number Diff line number Diff line change @@ -24,12 +24,12 @@ pub enum Baz {
24
24
25
25
}
26
26
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 {
29
29
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 , "" ) ,
33
33
}
34
34
}
35
35
}
You can’t perform that action at this time.
0 commit comments