Don't wrap 1-tuples in parens

This commit is contained in:
Richard Feldman 2022-05-28 19:23:40 -04:00
parent 7ded31cbc3
commit 8369e376b0
No known key found for this signature in database
GPG Key ID: 7E4127D1E4241798

View File

@ -1570,7 +1570,29 @@ fn tag_union_struct_help<'a, I: Iterator<Item = &'a (L, TypeId)>, L: Display + P
.collect::<Vec<String>>()
.join("\n")
);
let owned_ret = {
let owned_ret;
let borrowed_ret;
let owned_ret_type;
let borrowed_ret_type;
if ret_types.len() == 1 {
owned_ret_type = ret_types.join("");
borrowed_ret_type = owned_ret_type.clone();
let ret_val = ret_values.first().unwrap();
owned_ret = format!("\n{INDENT}{INDENT}{ret_val}");
borrowed_ret = format!("\n{INDENT}{INDENT}&{ret_val}");
} else {
owned_ret_type = format!("({})", ret_types.join(", "));
borrowed_ret_type = format!(
"({})",
ret_types
.iter()
.map(|ret_type| { format!("&{ret_type}") })
.collect::<Vec<String>>()
.join(", ")
);
owned_ret = {
let lines = ret_values
.iter()
.map(|line| format!("\n{INDENT}{INDENT}{INDENT}{line}"))
@ -1579,7 +1601,7 @@ fn tag_union_struct_help<'a, I: Iterator<Item = &'a (L, TypeId)>, L: Display + P
format!("({lines}\n{INDENT}{INDENT})")
};
let borrowed_ret = {
borrowed_ret = {
let lines = ret_values
.iter()
.map(|line| format!("\n{INDENT}{INDENT}{INDENT}&{line}"))
@ -1588,15 +1610,7 @@ fn tag_union_struct_help<'a, I: Iterator<Item = &'a (L, TypeId)>, L: Display + P
format!("({lines}\n{INDENT}{INDENT})")
};
let owned_ret_type = format!("({})", ret_types.join(", "));
let borrowed_ret_type = format!(
"({})",
ret_types
.iter()
.map(|ret_type| { format!("&{ret_type}") })
.collect::<Vec<String>>()
.join(", ")
);
}
StructIngredients {
payload_args,