Skip to content

Commit

Permalink
[Rust] [Axum] Fix clippy warning: to_string_trait_impl (#17995)
Browse files Browse the repository at this point in the history
* [Rust] [Axum] Fix clippy warning

* Using Display trait
  • Loading branch information
linxGnu committed Mar 1, 2024
1 parent d3ebb0a commit cdf8973
Show file tree
Hide file tree
Showing 13 changed files with 491 additions and 247 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -387,9 +387,9 @@ impl std::convert::From<{{{dataType}}}> for {{{classname}}} {
}
{{#vendorExtensions.x-is-string}}
impl std::string::ToString for {{{classname}}} {
fn to_string(&self) -> String {
self.0.to_string()
impl std::fmt::Display for {{{classname}}} {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{:?}", self.0)
}
}

Expand Down Expand Up @@ -424,10 +424,10 @@ impl std::ops::DerefMut for {{{classname}}} {
/// Converts the {{{classname}}} value to the Query Parameters representation (style=form, explode=false)
/// specified in https://swagger.io/docs/specification/serialization/
/// Should be implemented in a serde serializer
impl ::std::string::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 {
// Skipping additionalProperties in query parameter serialization
"".to_string()
write!(f, "")
}
}
Expand Down Expand Up @@ -517,9 +517,9 @@ impl std::ops::DerefMut for {{{classname}}} {
/// Converts the {{{classname}}} value to the Query Parameters representation (style=form, explode=false)
/// specified in https://swagger.io/docs/specification/serialization/
/// Should be implemented in a serde serializer
impl std::string::ToString for {{{classname}}} {
fn to_string(&self) -> String {
self.iter().map(|x| x.to_string()).collect::<Vec<_>>().join(",")
impl std::fmt::Display for {{{classname}}} {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{}", self.iter().map(|x| x.to_string()).collect::<Vec<_>>().join(","))
}
}
Expand Down Expand Up @@ -726,8 +726,8 @@ impl {{{classname}}} {
/// Converts the {{{classname}}} value to the Query Parameters representation (style=form, explode=false)
/// specified in https://swagger.io/docs/specification/serialization/
/// Should be implemented in a serde serializer
impl std::string::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 {
let params: Vec<Option<String>> = vec![
{{#vars}}
{{#isByteArray}}
Expand Down Expand Up @@ -789,7 +789,7 @@ impl std::string::ToString for {{{classname}}} {
{{/vars}}
];

params.into_iter().flatten().collect::<Vec<_>>().join(",")
write!(f, "{}", params.into_iter().flatten().collect::<Vec<_>>().join(","))
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
7.3.0-SNAPSHOT
7.4.0-SNAPSHOT
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ impl MultipartRelatedRequest {
/// Converts the MultipartRelatedRequest value to the Query Parameters representation (style=form, explode=false)
/// specified in https://swagger.io/docs/specification/serialization/
/// Should be implemented in a serde serializer
impl std::string::ToString for MultipartRelatedRequest {
fn to_string(&self) -> String {
impl std::fmt::Display for MultipartRelatedRequest {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
let params: Vec<Option<String>> = vec![
// Skipping object_field in query parameter serialization

Expand All @@ -49,7 +49,11 @@ impl std::string::ToString for MultipartRelatedRequest {

];

params.into_iter().flatten().collect::<Vec<_>>().join(",")
write!(
f,
"{}",
params.into_iter().flatten().collect::<Vec<_>>().join(",")
)
}
}

Expand Down Expand Up @@ -184,8 +188,8 @@ impl MultipartRequestObjectField {
/// Converts the MultipartRequestObjectField value to the Query Parameters representation (style=form, explode=false)
/// specified in https://swagger.io/docs/specification/serialization/
/// Should be implemented in a serde serializer
impl std::string::ToString for MultipartRequestObjectField {
fn to_string(&self) -> String {
impl std::fmt::Display for MultipartRequestObjectField {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
let params: Vec<Option<String>> = vec![
Some("field_a".to_string()),
Some(self.field_a.to_string()),
Expand All @@ -202,7 +206,11 @@ impl std::string::ToString for MultipartRequestObjectField {
}),
];

params.into_iter().flatten().collect::<Vec<_>>().join(",")
write!(
f,
"{}",
params.into_iter().flatten().collect::<Vec<_>>().join(",")
)
}
}

Expand Down Expand Up @@ -333,8 +341,8 @@ impl MultipleIdenticalMimeTypesPostRequest {
/// Converts the MultipleIdenticalMimeTypesPostRequest value to the Query Parameters representation (style=form, explode=false)
/// specified in https://swagger.io/docs/specification/serialization/
/// Should be implemented in a serde serializer
impl std::string::ToString for MultipleIdenticalMimeTypesPostRequest {
fn to_string(&self) -> String {
impl std::fmt::Display for MultipleIdenticalMimeTypesPostRequest {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
let params: Vec<Option<String>> = vec![
// Skipping binary1 in query parameter serialization
// Skipping binary1 in query parameter serialization
Expand All @@ -344,7 +352,11 @@ impl std::string::ToString for MultipleIdenticalMimeTypesPostRequest {

];

params.into_iter().flatten().collect::<Vec<_>>().join(",")
write!(
f,
"{}",
params.into_iter().flatten().collect::<Vec<_>>().join(",")
)
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
7.3.0-SNAPSHOT
7.4.0-SNAPSHOT
Loading

0 comments on commit cdf8973

Please sign in to comment.