rustc: Use the new for protocol
This commit is contained in:
parent
5eb6d19803
commit
a87db3e2cd
16 changed files with 628 additions and 19 deletions
|
|
@ -199,6 +199,7 @@ pub mod reader {
|
|||
}
|
||||
}
|
||||
|
||||
#[cfg(stage0)]
|
||||
pub fn docs(d: Doc, it: &fn(uint, Doc) -> bool) {
|
||||
let mut pos = d.start;
|
||||
while pos < d.end {
|
||||
|
|
@ -211,7 +212,22 @@ pub mod reader {
|
|||
}
|
||||
}
|
||||
}
|
||||
#[cfg(not(stage0))]
|
||||
pub fn docs(d: Doc, it: &fn(uint, Doc) -> bool) -> bool {
|
||||
let mut pos = d.start;
|
||||
while pos < d.end {
|
||||
let elt_tag = vuint_at(*d.data, pos);
|
||||
let elt_size = vuint_at(*d.data, elt_tag.next);
|
||||
pos = elt_size.next + elt_size.val;
|
||||
let doc = Doc { data: d.data, start: elt_size.next, end: pos };
|
||||
if !it(elt_tag.val, doc) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
#[cfg(stage0)]
|
||||
pub fn tagged_docs(d: Doc, tg: uint, it: &fn(Doc) -> bool) {
|
||||
let mut pos = d.start;
|
||||
while pos < d.end {
|
||||
|
|
@ -227,6 +243,23 @@ pub mod reader {
|
|||
}
|
||||
}
|
||||
}
|
||||
#[cfg(not(stage0))]
|
||||
pub fn tagged_docs(d: Doc, tg: uint, it: &fn(Doc) -> bool) -> bool {
|
||||
let mut pos = d.start;
|
||||
while pos < d.end {
|
||||
let elt_tag = vuint_at(*d.data, pos);
|
||||
let elt_size = vuint_at(*d.data, elt_tag.next);
|
||||
pos = elt_size.next + elt_size.val;
|
||||
if elt_tag.val == tg {
|
||||
let doc = Doc { data: d.data, start: elt_size.next,
|
||||
end: pos };
|
||||
if !it(doc) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
pub fn doc_data(d: Doc) -> ~[u8] {
|
||||
vec::slice::<u8>(*d.data, d.start, d.end).to_vec()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue