Implement formatter for anon binop.
This commit is contained in:
parent
91f03abb7b
commit
4252ee6373
|
@ -775,11 +775,8 @@ impl<'comments> Formatter<'comments> {
|
||||||
|
|
||||||
UntypedExpr::Fn {
|
UntypedExpr::Fn {
|
||||||
fn_style: FnStyle::BinOp(op),
|
fn_style: FnStyle::BinOp(op),
|
||||||
body,
|
|
||||||
..
|
..
|
||||||
} => {
|
} => op.to_doc(),
|
||||||
unimplemented!()
|
|
||||||
}
|
|
||||||
|
|
||||||
UntypedExpr::Fn {
|
UntypedExpr::Fn {
|
||||||
fn_style: FnStyle::Plain,
|
fn_style: FnStyle::Plain,
|
||||||
|
@ -1070,7 +1067,9 @@ impl<'comments> Formatter<'comments> {
|
||||||
let right = self.expr(right);
|
let right = self.expr(right);
|
||||||
|
|
||||||
self.operator_side(left, precedence, left_precedence)
|
self.operator_side(left, precedence, left_precedence)
|
||||||
|
.append(" ")
|
||||||
.append(name)
|
.append(name)
|
||||||
|
.append(" ")
|
||||||
.append(self.operator_side(right, precedence, right_precedence - 1))
|
.append(self.operator_side(right, precedence, right_precedence - 1))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -864,3 +864,26 @@ fn hex_and_numeric_underscore() {
|
||||||
|
|
||||||
assert_fmt(src, src);
|
assert_fmt(src, src);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn first_class_binop() {
|
||||||
|
let src = indoc! { r#"
|
||||||
|
fn foo() {
|
||||||
|
compare_with(a, >, b)
|
||||||
|
compare_with(a, >=, b)
|
||||||
|
compare_with(a, <, b)
|
||||||
|
compare_with(a, <=, b)
|
||||||
|
compare_with(a, ==, b)
|
||||||
|
compare_with(a, !=, b)
|
||||||
|
combine_with(a, &&, b)
|
||||||
|
combine_with(a, ||, b)
|
||||||
|
compute_with(a, +, b)
|
||||||
|
compute_with(a, -, b)
|
||||||
|
compute_with(a, /, b)
|
||||||
|
compute_with(a, *, b)
|
||||||
|
compute_with(a, %, b)
|
||||||
|
}
|
||||||
|
"#};
|
||||||
|
|
||||||
|
assert_fmt(src, src);
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue