rustc: Use coherence for operator overloading.
The only use of the old-style impls is now placement new.
This commit is contained in:
parent
e6d2e49852
commit
93c2f5e0e4
23 changed files with 348 additions and 295 deletions
|
|
@ -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 {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue