Re-use expr formatter for constants.

This commit is contained in:
KtorZ 2024-08-17 14:56:18 +02:00
parent f35afe8d65
commit 9063549f2e
No known key found for this signature in database
GPG Key ID: 33173CB6F77F4277
1 changed files with 1 additions and 7 deletions

View File

@ -295,7 +295,7 @@ impl<'comments> Formatter<'comments> {
head.append(" =")
.append(break_("", " "))
.append(self.const_expr(value))
.append(self.expr(value, true))
.nest(INDENT)
.group()
}
@ -338,12 +338,6 @@ impl<'comments> Formatter<'comments> {
})
}
fn const_expr<'a>(&mut self, _value: &'a UntypedExpr) -> Document<'a> {
todo!(
"format const_expr: surround complex expressions with a block, and leave simple expression without"
);
}
pub fn docs_const_expr<'a>(&mut self, name: &'a str, value: &'a TypedExpr) -> Document<'a> {
let mut printer = tipo::pretty::Printer::new();
name.to_doc()