do the composed lists

This commit is contained in:
amtoine 2023-03-11 12:00:03 +01:00
parent 496d45cffa
commit e354bb766d
No known key found for this signature in database
GPG Key ID: 37AAE9B486CFF1AB

View File

@ -103,6 +103,7 @@ pub fn value_to_string(
let nl = get_true_newline(indent); let nl = get_true_newline(indent);
let idt = get_true_indentation(depth, indent); let idt = get_true_indentation(depth, indent);
let idt_po = get_true_indentation(depth + 1, indent); let idt_po = get_true_indentation(depth + 1, indent);
let idt_pt = get_true_indentation(depth + 2, indent);
match v { match v {
Value::Binary { val, .. } => { Value::Binary { val, .. } => {
@ -178,13 +179,13 @@ pub fn value_to_string(
.iter() .iter()
.map(|string| { .map(|string| {
if needs_quotes(string) { if needs_quotes(string) {
format!("\"{string}\"") format!("{idt}\"{string}\"")
} else { } else {
string.to_string() format!("{idt}{string}")
} }
}) })
.collect(); .collect();
let headers_output = headers.join(", "); let headers_output = headers.join(&format!(", {nl}{idt_pt}").to_string());
let mut table_output = vec![]; let mut table_output = vec![];
for val in vals { for val in vals {
@ -195,19 +196,19 @@ pub fn value_to_string(
row.push(value_to_string_without_quotes( row.push(value_to_string_without_quotes(
val, val,
span, span,
depth + 1, depth + 2,
indent, indent,
)?); )?);
} }
} }
table_output.push(row.join(", ")); table_output.push(row.join(&format!(", {nl}{idt_pt}").to_string()));
} }
Ok(format!( Ok(format!(
"[[{}]; [{}]]", "[{nl}{idt_po}[{nl}{idt_pt}{}{nl}{idt_po}]; {nl}{idt_po}[{nl}{idt_pt}{}{nl}{idt_po}]{nl}{idt}]",
headers_output, headers_output,
table_output.join("], [") table_output.join(&format!("{nl}{idt_po}], {nl}{idt_po}[{nl}{idt_pt}").to_string())
)) ))
} else { } else {
let mut collection = vec![]; let mut collection = vec![];