Migrate Context::maybe_ignore_item method to standalone function.

The method wasn't using any `self` data from Context, so it seemed
miseading to implement it as a method.
This commit is contained in:
Corey Farwell 2016-08-20 14:22:08 -04:00
parent 28ecfb691d
commit 7dc411667a

View File

@ -1353,7 +1353,7 @@ fn item<F>(&mut self, item: clean::Item, mut f: F) -> Result<(), Error> where
// these modules are recursed into, but not rendered normally
// (a flag on the context).
if !self.render_redirect_pages {
self.render_redirect_pages = self.maybe_ignore_item(&item);
self.render_redirect_pages = maybe_ignore_item(&item);
}
if item.is_mod() {
@ -1436,7 +1436,7 @@ fn build_sidebar_items(&self, m: &clean::Module) -> BTreeMap<String, Vec<NameDoc
// BTreeMap instead of HashMap to get a sorted output
let mut map = BTreeMap::new();
for item in &m.items {
if self.maybe_ignore_item(item) { continue }
if maybe_ignore_item(item) { continue }
let short = item_type(item).css_class();
let myname = match item.name {
@ -1453,17 +1453,6 @@ fn build_sidebar_items(&self, m: &clean::Module) -> BTreeMap<String, Vec<NameDoc
}
return map;
}
fn maybe_ignore_item(&self, it: &clean::Item) -> bool {
match it.inner {
clean::StrippedItem(..) => true,
clean::ModuleItem(ref m) => {
it.doc_value().is_none() && m.items.is_empty()
&& it.visibility != Some(clean::Public)
},
_ => false,
}
}
}
impl<'a> Item<'a> {
@ -1706,7 +1695,7 @@ fn item_module(w: &mut fmt::Formatter, cx: &Context,
if let clean::DefaultImplItem(..) = items[*i].inner {
return false;
}
!cx.maybe_ignore_item(&items[*i])
!maybe_ignore_item(&items[*i])
}).collect::<Vec<usize>>();
// the order of item types in the listing
@ -1854,6 +1843,17 @@ fn cmp(i1: &clean::Item, i2: &clean::Item, idx1: usize, idx2: usize) -> Ordering
Ok(())
}
fn maybe_ignore_item(it: &clean::Item) -> bool {
match it.inner {
clean::StrippedItem(..) => true,
clean::ModuleItem(ref m) => {
it.doc_value().is_none() && m.items.is_empty()
&& it.visibility != Some(clean::Public)
},
_ => false,
}
}
fn short_stability(item: &clean::Item, cx: &Context, show_reason: bool) -> Vec<String> {
let mut stability = vec![];