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

@ -27,6 +27,8 @@ export serializer;
export ebml_deserializer;
export deserializer;
export with_doc_data;
export get_doc;
export extensions;
type ebml_tag = {id: uint, size: uint};
@ -40,6 +42,24 @@ type doc = {data: @~[u8], start: uint, end: uint};
type tagged_doc = {tag: uint, doc: doc};
trait get_doc {
fn [](tag: uint) -> doc;
}
impl extensions of get_doc for doc {
fn [](tag: uint) -> doc {
get_doc(self, tag)
}
}
impl extensions of ops::index<uint,doc> for doc {
pure fn index(&&tag: uint) -> doc {
unchecked {
get_doc(self, tag)
}
}
}
fn vuint_at(data: &[u8], start: uint) -> {val: uint, next: uint} {
let a = data[start];
if a & 0x80u8 != 0u8 {