Skip to content

Commit 7efaf3f

Browse files
author
Jorge Aparicio
committed
syntax/ast_util: add is_by_value_unop()
1 parent f9a4849 commit 7efaf3f

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/libsyntax/ast_util.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ pub fn is_shift_binop(b: BinOp) -> bool {
8585
}
8686
}
8787

88-
/// Returns `true` is the binary operator takes its arguments by value
88+
/// Returns `true` if the binary operator takes its arguments by value
8989
pub fn is_by_value_binop(b: BinOp) -> bool {
9090
match b {
9191
BiAdd | BiSub | BiMul | BiDiv | BiRem | BiBitXor | BiBitAnd | BiBitOr | BiShl | BiShr => {
@@ -95,6 +95,14 @@ pub fn is_by_value_binop(b: BinOp) -> bool {
9595
}
9696
}
9797

98+
/// Returns `true` if the unary operator takes its argument by value
99+
pub fn is_by_value_unop(u: UnOp) -> bool {
100+
match u {
101+
UnNeg | UnNot => true,
102+
_ => false,
103+
}
104+
}
105+
98106
pub fn unop_to_string(op: UnOp) -> &'static str {
99107
match op {
100108
UnUniq => "box() ",

0 commit comments

Comments
 (0)