diff options
| author | Eduard Burtescu <edy.burt@gmail.com> | 2014-02-24 10:33:50 +0200 |
|---|---|---|
| committer | Eduard Burtescu <edy.burt@gmail.com> | 2014-02-25 19:08:54 +0200 |
| commit | d096eefd8016103b524a6ef39a9d42092e51fc69 (patch) | |
| tree | 797231e75509963c4722003d9ed602dc07351d19 /src/libsyntax | |
| parent | 818203e9d25f99cb6fcdf7210c512bfb09f0956f (diff) | |
| download | rust-d096eefd8016103b524a6ef39a9d42092e51fc69.tar.gz rust-d096eefd8016103b524a6ef39a9d42092e51fc69.zip | |
Use only the appropriate trait when looking up operator overloads.
Diffstat (limited to 'src/libsyntax')
| -rw-r--r-- | src/libsyntax/ast_util.rs | 60 |
1 files changed, 19 insertions, 41 deletions
diff --git a/src/libsyntax/ast_util.rs b/src/libsyntax/ast_util.rs index 8ff66bc6629..f6066e5385d 100644 --- a/src/libsyntax/ast_util.rs +++ b/src/libsyntax/ast_util.rs @@ -79,48 +79,26 @@ pub fn def_id_of_def(d: Def) -> DefId { } } -pub fn binop_to_str(op: BinOp) -> ~str { +pub fn binop_to_str(op: BinOp) -> &'static str { match op { - BiAdd => return ~"+", - BiSub => return ~"-", - BiMul => return ~"*", - BiDiv => return ~"/", - BiRem => return ~"%", - BiAnd => return ~"&&", - BiOr => return ~"||", - BiBitXor => return ~"^", - BiBitAnd => return ~"&", - BiBitOr => return ~"|", - BiShl => return ~"<<", - BiShr => return ~">>", - BiEq => return ~"==", - BiLt => return ~"<", - BiLe => return ~"<=", - BiNe => return ~"!=", - BiGe => return ~">=", - BiGt => return ~">" - } -} - -pub fn binop_to_method_name(op: BinOp) -> Option<~str> { - match op { - BiAdd => return Some(~"add"), - BiSub => return Some(~"sub"), - BiMul => return Some(~"mul"), - BiDiv => return Some(~"div"), - BiRem => return Some(~"rem"), - BiBitXor => return Some(~"bitxor"), - BiBitAnd => return Some(~"bitand"), - BiBitOr => return Some(~"bitor"), - BiShl => return Some(~"shl"), - BiShr => return Some(~"shr"), - BiLt => return Some(~"lt"), - BiLe => return Some(~"le"), - BiGe => return Some(~"ge"), - BiGt => return Some(~"gt"), - BiEq => return Some(~"eq"), - BiNe => return Some(~"ne"), - BiAnd | BiOr => return None + BiAdd => "+", + BiSub => "-", + BiMul => "*", + BiDiv => "/", + BiRem => "%", + BiAnd => "&&", + BiOr => "||", + BiBitXor => "^", + BiBitAnd => "&", + BiBitOr => "|", + BiShl => "<<", + BiShr => ">>", + BiEq => "==", + BiLt => "<", + BiLe => "<=", + BiNe => "!=", + BiGe => ">=", + BiGt => ">" } } |
