rustc: Use coherence for operator overloading.

The only use of the old-style impls is now placement new.
This commit is contained in:
Patrick Walton 2012-07-27 19:32:42 -07:00
parent e6d2e49852
commit 93c2f5e0e4
23 changed files with 348 additions and 295 deletions

View file

@ -87,6 +87,22 @@ pure fn binop_to_str(op: binop) -> ~str {
}
}
pure fn binop_to_method_name(op: binop) -> option<~str> {
alt op {
add { ret some(~"add"); }
subtract { ret some(~"sub"); }
mul { ret some(~"mul"); }
div { ret some(~"div"); }
rem { ret some(~"modulo"); }
bitxor { ret some(~"bitxor"); }
bitand { ret some(~"bitand"); }
bitor { ret some(~"bitor"); }
shl { ret some(~"shl"); }
shr { ret some(~"shr"); }
and | or | eq | lt | le | ne | ge | gt { ret none; }
}
}
pure fn lazy_binop(b: binop) -> bool {
alt b { and { true } or { true } _ { false } }
}