about summary refs log tree commit diff
path: root/src/libsyntax
diff options
context:
space:
mode:
authorJorge Aparicio <japaricious@gmail.com>2014-12-01 11:34:28 -0500
committerJorge Aparicio <japaricious@gmail.com>2014-12-13 20:11:13 -0500
commit14c0a708cc33245d86d48b99d7dc93a6f5b9d20d (patch)
tree3152f2717309fcee3fed6fe12da4874a65735767 /src/libsyntax
parent444fa1b7cffcd99ca5b8abb51acf979f06a25899 (diff)
downloadrust-14c0a708cc33245d86d48b99d7dc93a6f5b9d20d.tar.gz
rust-14c0a708cc33245d86d48b99d7dc93a6f5b9d20d.zip
syntax/ast_util: add `is_by_value_binop()`
Diffstat (limited to 'src/libsyntax')
-rw-r--r--src/libsyntax/ast_util.rs10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/libsyntax/ast_util.rs b/src/libsyntax/ast_util.rs
index 7579972c6d8..71ce4847922 100644
--- a/src/libsyntax/ast_util.rs
+++ b/src/libsyntax/ast_util.rs
@@ -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() ",