]> git.lizzy.rs Git - rust.git/commitdiff
syntax/ast_util: add `is_by_value_binop()`
authorJorge Aparicio <japaricious@gmail.com>
Mon, 1 Dec 2014 16:34:28 +0000 (11:34 -0500)
committerJorge Aparicio <japaricious@gmail.com>
Sun, 14 Dec 2014 01:11:13 +0000 (20:11 -0500)
src/libsyntax/ast_util.rs

index 7579972c6d84337a164e17683d39bbf28fd4a7b3..71ce4847922d356de331fe2843bd2f0ccec0c07d 100644 (file)
@@ -85,6 +85,16 @@ pub fn is_shift_binop(b: BinOp) -> bool {
     }
 }
 
+/// Returns `true` is the binary operator takes its arguments by value
+pub fn is_by_value_binop(b: BinOp) -> bool {
+    match b {
+        BiAdd | BiSub | BiMul | BiDiv | BiRem | BiBitXor | BiBitAnd | BiBitOr | BiShl | BiShr => {
+            true
+        }
+        _ => false
+    }
+}
+
 pub fn unop_to_string(op: UnOp) -> &'static str {
     match op {
       UnUniq => "box() ",