]> git.lizzy.rs Git - rust.git/commitdiff
syntax/ast_util: add `is_by_value_unop()`
authorJorge Aparicio <japaricious@gmail.com>
Mon, 15 Dec 2014 20:49:41 +0000 (15:49 -0500)
committerJorge Aparicio <japaricious@gmail.com>
Thu, 18 Dec 2014 19:56:00 +0000 (14:56 -0500)
src/libsyntax/ast_util.rs

index aaa172633be2123c860bf6beb2f8ab9fd01589e9..5243f07f32749f62fdc7787489a6dec391cf2782 100644 (file)
@@ -85,7 +85,7 @@ pub fn is_shift_binop(b: BinOp) -> bool {
     }
 }
 
-/// Returns `true` is the binary operator takes its arguments by value
+/// Returns `true` if 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 => {
@@ -95,6 +95,14 @@ pub fn is_by_value_binop(b: BinOp) -> bool {
     }
 }
 
+/// Returns `true` if the unary operator takes its argument by value
+pub fn is_by_value_unop(u: UnOp) -> bool {
+    match u {
+        UnNeg | UnNot => true,
+        _ => false,
+    }
+}
+
 pub fn unop_to_string(op: UnOp) -> &'static str {
     match op {
       UnUniq => "box() ",