rustdoc: Extract converter from Impementor to Item to a fn
This commit is contained in:
parent
3c96d40d32
commit
87d7520d0f
@ -2253,6 +2253,18 @@ fn item_function(w: &mut fmt::Formatter, cx: &Context, it: &clean::Item,
|
||||
document(w, cx, it)
|
||||
}
|
||||
|
||||
fn implementor2item<'a>(cache: &'a Cache, imp : &Implementor) -> Option<&'a clean::Item> {
|
||||
if let Some(t_did) = imp.impl_.for_.def_id() {
|
||||
if let Some(impl_item) = cache.impls.get(&t_did).and_then(|i| i.iter()
|
||||
.find(|i| i.impl_item.def_id == imp.def_id))
|
||||
{
|
||||
let i = &impl_item.impl_item;
|
||||
return Some(i);
|
||||
}
|
||||
}
|
||||
None
|
||||
}
|
||||
|
||||
fn item_trait(w: &mut fmt::Formatter, cx: &Context, it: &clean::Item,
|
||||
t: &clean::Trait) -> fmt::Result {
|
||||
let mut bounds = String::new();
|
||||
@ -2463,12 +2475,7 @@ fn item_trait(w: &mut fmt::Formatter, cx: &Context, it: &clean::Item,
|
||||
")?;
|
||||
|
||||
for implementor in foreign {
|
||||
// need to get from a clean::Impl to a clean::Item so i can use render_impl
|
||||
if let Some(t_did) = implementor.impl_.for_.def_id() {
|
||||
if let Some(impl_item) = cache.impls.get(&t_did).and_then(|i| i.iter()
|
||||
.find(|i| i.impl_item.def_id == implementor.def_id))
|
||||
{
|
||||
let i = &impl_item.impl_item;
|
||||
if let Some(i) = implementor2item(&cache, implementor) {
|
||||
let impl_ = Impl { impl_item: i.clone() };
|
||||
let assoc_link = AssocItemLink::GotoSource(
|
||||
i.def_id, &implementor.impl_.provided_trait_methods
|
||||
@ -2478,7 +2485,6 @@ fn item_trait(w: &mut fmt::Formatter, cx: &Context, it: &clean::Item,
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
write!(w, "{}", impl_header)?;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user