diff --git a/codegenerator/templates/rust_cli/response_struct.j2 b/codegenerator/templates/rust_cli/response_struct.j2 index b722576..f4870c7 100644 --- a/codegenerator/templates/rust_cli/response_struct.j2 +++ b/codegenerator/templates/rust_cli/response_struct.j2 @@ -73,7 +73,7 @@ {%- elif data_type.value_type.type_hint == "String" %} .map(|(k, v)| Vec::from([k.clone(), v.clone()])), {%- elif data_type.value_type.__class__.__name__ == "Option" %} - .map(|(k, v)| Vec::from([k.clone(), v.clone().unwrap_or("".to_string()).to_string()])), + .map(|(k, v)| Vec::from([k.clone(), v.clone().unwrap_or(String::new()).to_string()])), {%- else %} .map(|(k, v)| Vec::from([k.clone(), v.to_string()])), {%- endif %} @@ -109,8 +109,7 @@ impl fmt::Display for {{ subtype.name }} { {%- if v.type_hint not in ["Option", "Option", "Option", "Option", "Option"] %} .clone() {%- endif %} - .map(|v| v.to_string()) - .unwrap_or("".to_string()) + .map_or(String::new(), |v| v.to_string()) {%- endif %} ), {%- endfor %} @@ -158,7 +157,7 @@ impl fmt::Display for {{ subtype.type_hint }} { self.0 .iter() {%- if subtype.value_type.__class__.__name__ == "Option" %} - .map(|v| format!("{}={}", v.0, v.1.clone().unwrap_or("".to_string()))) + .map(|v| format!("{}={}", v.0, v.1.clone().unwrap_or(String::new()))) {%- else %} .map(|v| format!("{}={}", v.0, v.1)) {%- endif %} diff --git a/codegenerator/templates/rust_macros.j2 b/codegenerator/templates/rust_macros.j2 index 2fee35e..44976a2 100644 --- a/codegenerator/templates/rust_macros.j2 +++ b/codegenerator/templates/rust_macros.j2 @@ -364,7 +364,7 @@ Some({{ val }}) {%- else %} {#- Normal array #} {{ dst_var }}.{{ param.remote_name }}( - {{ val_var }}.iter().map(|v| v.into()).collect::>() + {{ val_var }}.iter().map(Into::into).collect::>() ); {%- endif %} {%- endmacro %}