Skip to content

Commit 8aa55e7

Browse files
committed
Refactor
1 parent 9b8e000 commit 8aa55e7

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

src/libsyntax_ext/assert.rs

+9-10
Original file line numberDiff line numberDiff line change
@@ -409,16 +409,8 @@ impl<'cx, 'a: 'cx> Context<'cx, 'a> {
409409

410410
match expr.node {
411411
CondExprKind::BinOp(op, left, right) => {
412-
let left_by_ref = if let CondExprKind::Capture(.., mode) = left.node {
413-
mode.is_by_ref()
414-
} else {
415-
false
416-
};
417-
let right_by_ref = if let CondExprKind::Capture(.., mode) = right.node {
418-
mode.is_by_ref()
419-
} else {
420-
false
421-
};
412+
let left_by_ref = left.is_by_ref_capture();
413+
let right_by_ref = right.is_by_ref_capture();
422414

423415
let with_left = Action::Value(Rc::new(move |left, is_evaluated| {
424416
let action = action.clone();
@@ -663,6 +655,13 @@ impl CondExpr {
663655
matches!(self.node, CondExprKind::Capture(..))
664656
}
665657

658+
fn is_by_ref_capture(&self) -> bool {
659+
matches!(
660+
self.node,
661+
CondExprKind::Capture(_, _, BindingMode::ByRef(_))
662+
)
663+
}
664+
666665
fn is_lazy_binop(&self) -> bool {
667666
if let CondExprKind::BinOp(op, ..) = self.node {
668667
op.lazy()

0 commit comments

Comments
 (0)