Skip to content

Commit 1ed1e3d

Browse files
committed
Fix formatting
1 parent e769a54 commit 1ed1e3d

File tree

1 file changed

+9
-22
lines changed

1 file changed

+9
-22
lines changed

crates/ra_assists/src/assists/apply_demorgan.rs

Lines changed: 9 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
//! This assist transforms boolean expressions of the form `!a || !b` into
33
//! `!(a && b)`.
44
use hir::db::HirDatabase;
5-
use ra_syntax::SyntaxNode;
65
use ra_syntax::ast::{AstNode, BinExpr, BinOp, Expr, PrefixOp};
6+
use ra_syntax::SyntaxNode;
77

88
use crate::{Assist, AssistCtx, AssistId};
99

@@ -25,16 +25,16 @@ fn undo_negation(node: SyntaxNode) -> Option<String> {
2525
let rhs = bin.rhs()?.syntax().text();
2626
Some(format!("{} == {}", lhs, rhs))
2727
}
28-
_ => None
29-
}
28+
_ => None,
29+
},
3030
Expr::PrefixExpr(pe) => match pe.op_kind()? {
3131
PrefixOp::Not => {
3232
let child = pe.expr()?.syntax().text();
3333
Some(String::from(child))
3434
}
35-
_ => None
36-
}
37-
_ => None
35+
_ => None,
36+
},
37+
_ => None,
3838
}
3939
}
4040

@@ -60,7 +60,6 @@ pub(crate) fn apply_demorgan(mut ctx: AssistCtx<impl HirDatabase>) -> Option<Ass
6060
let not_lhs = undo_negation(lhs)?;
6161
let not_rhs = undo_negation(rhs)?;
6262

63-
6463
ctx.add_action(AssistId("apply_demorgan"), "apply demorgan's law", |edit| {
6564
edit.target(op_range);
6665
edit.replace(op_range, opposite_op);
@@ -78,29 +77,17 @@ mod tests {
7877

7978
#[test]
8079
fn demorgan_turns_and_into_or() {
81-
check_assist(
82-
apply_demorgan,
83-
"fn f() { !x &&<|> !x }",
84-
"fn f() { !(x ||<|> x) }"
85-
)
80+
check_assist(apply_demorgan, "fn f() { !x &&<|> !x }", "fn f() { !(x ||<|> x) }")
8681
}
8782

8883
#[test]
8984
fn demorgan_turns_or_into_and() {
90-
check_assist(
91-
apply_demorgan,
92-
"fn f() { !x ||<|> !x }",
93-
"fn f() { !(x &&<|> x) }"
94-
)
85+
check_assist(apply_demorgan, "fn f() { !x ||<|> !x }", "fn f() { !(x &&<|> x) }")
9586
}
9687

9788
#[test]
9889
fn demorgan_removes_inequality() {
99-
check_assist(
100-
apply_demorgan,
101-
"fn f() { x != x ||<|> !x }",
102-
"fn f() { !(x == x &&<|> x) }"
103-
)
90+
check_assist(apply_demorgan, "fn f() { x != x ||<|> !x }", "fn f() { !(x == x &&<|> x) }")
10491
}
10592

10693
#[test]

0 commit comments

Comments
 (0)