Return the iterator from reader::docs.
This commit is contained in:
parent
de9deefb22
commit
fb7c0b44bb
3 changed files with 11 additions and 21 deletions
|
|
@ -397,12 +397,10 @@ pub mod reader {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn docs<F>(d: Doc, mut it: F) -> bool where
|
||||
F: FnMut(usize, Doc) -> bool,
|
||||
{
|
||||
DocsIterator { d: d }.all(|(value, doc)| {
|
||||
it(value, doc)
|
||||
})
|
||||
pub fn docs<'a>(d: Doc<'a>) -> DocsIterator<'a> {
|
||||
DocsIterator {
|
||||
d: d
|
||||
}
|
||||
}
|
||||
|
||||
pub struct DocsIterator<'a> {
|
||||
|
|
|
|||
|
|
@ -275,25 +275,18 @@ fn enum_variant_ids(item: rbml::Doc, cdata: Cmd) -> Vec<ast::DefId> {
|
|||
|
||||
fn item_path(item_doc: rbml::Doc) -> Vec<ast_map::PathElem> {
|
||||
let path_doc = reader::get_doc(item_doc, tag_path);
|
||||
|
||||
let len_doc = reader::get_doc(path_doc, tag_path_len);
|
||||
let len = reader::doc_as_u32(len_doc) as usize;
|
||||
|
||||
let mut result = Vec::with_capacity(len);
|
||||
reader::docs(path_doc, |tag, elt_doc| {
|
||||
reader::docs(path_doc).filter_map(|(tag, elt_doc)| {
|
||||
if tag == tag_path_elem_mod {
|
||||
let s = elt_doc.as_str_slice();
|
||||
result.push(ast_map::PathMod(token::intern(s)));
|
||||
Some(ast_map::PathMod(token::intern(s)))
|
||||
} else if tag == tag_path_elem_name {
|
||||
let s = elt_doc.as_str_slice();
|
||||
result.push(ast_map::PathName(token::intern(s)));
|
||||
Some(ast_map::PathName(token::intern(s)))
|
||||
} else {
|
||||
// ignore tag_path_len element
|
||||
None
|
||||
}
|
||||
true
|
||||
});
|
||||
|
||||
result
|
||||
}).collect()
|
||||
}
|
||||
|
||||
fn item_name(intr: &IdentInterner, item: rbml::Doc) -> ast::Name {
|
||||
|
|
|
|||
|
|
@ -1706,7 +1706,7 @@ impl<'a, 'tcx> rbml_decoder_decoder_helpers<'tcx> for reader::Decoder<'a> {
|
|||
fn decode_side_tables(dcx: &DecodeContext,
|
||||
ast_doc: rbml::Doc) {
|
||||
let tbl_doc = ast_doc.get(c::tag_table as usize);
|
||||
reader::docs(tbl_doc, |tag, entry_doc| {
|
||||
for (tag, entry_doc) in reader::docs(tbl_doc) {
|
||||
let mut entry_dsr = reader::Decoder::new(entry_doc);
|
||||
let id0: ast::NodeId = Decodable::decode(&mut entry_dsr).unwrap();
|
||||
let id = dcx.tr_id(id0);
|
||||
|
|
@ -1815,8 +1815,7 @@ fn decode_side_tables(dcx: &DecodeContext,
|
|||
}
|
||||
|
||||
debug!(">< Side table doc loaded");
|
||||
true
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// ______________________________________________________________________
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue