mirror of
https://github.com/rust-lang/rust.git
synced 2025-06-05 11:48:30 +00:00
Improve code readability
This commit is contained in:
parent
29777fc6cd
commit
0d52eb9de8
@ -1457,8 +1457,8 @@ fn render_impl(
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn render_default_items(
|
fn render_default_items(
|
||||||
w: &mut Buffer,
|
boring: &mut Buffer,
|
||||||
tmp_w: &mut Buffer,
|
interesting: &mut Buffer,
|
||||||
cx: &Context<'_>,
|
cx: &Context<'_>,
|
||||||
t: &clean::Trait,
|
t: &clean::Trait,
|
||||||
i: &clean::Impl,
|
i: &clean::Impl,
|
||||||
@ -1477,8 +1477,8 @@ fn render_impl(
|
|||||||
let assoc_link = AssocItemLink::GotoSource(did, &i.provided_trait_methods);
|
let assoc_link = AssocItemLink::GotoSource(did, &i.provided_trait_methods);
|
||||||
|
|
||||||
doc_impl_item(
|
doc_impl_item(
|
||||||
w,
|
boring,
|
||||||
tmp_w,
|
interesting,
|
||||||
cx,
|
cx,
|
||||||
trait_item,
|
trait_item,
|
||||||
parent,
|
parent,
|
||||||
@ -1513,10 +1513,14 @@ fn render_impl(
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let details_str = if impl_items.is_empty() && default_impl_items.is_empty() {
|
let toggled = !impl_items.is_empty() || !default_impl_items.is_empty();
|
||||||
""
|
let open_details = |close_tags: &mut String| {
|
||||||
} else {
|
if toggled {
|
||||||
"<details class=\"rustdoc-toggle implementors-toggle\" open><summary>"
|
close_tags.insert_str(0, "</details>");
|
||||||
|
"<details class=\"rustdoc-toggle implementors-toggle\" open><summary>"
|
||||||
|
} else {
|
||||||
|
""
|
||||||
|
}
|
||||||
};
|
};
|
||||||
if render_mode == RenderMode::Normal {
|
if render_mode == RenderMode::Normal {
|
||||||
let id = cx.derive_id(match i.inner_impl().trait_ {
|
let id = cx.derive_id(match i.inner_impl().trait_ {
|
||||||
@ -1538,11 +1542,10 @@ fn render_impl(
|
|||||||
write!(
|
write!(
|
||||||
w,
|
w,
|
||||||
"{}<h3 id=\"{}\" class=\"impl\"{}><code class=\"in-band\">",
|
"{}<h3 id=\"{}\" class=\"impl\"{}><code class=\"in-band\">",
|
||||||
details_str, id, aliases
|
open_details(&mut close_tags),
|
||||||
|
id,
|
||||||
|
aliases
|
||||||
);
|
);
|
||||||
if !impl_items.is_empty() || !default_impl_items.is_empty() {
|
|
||||||
close_tags.insert_str(0, "</details>");
|
|
||||||
}
|
|
||||||
write!(w, "{}", i.inner_impl().print(use_absolute, cx));
|
write!(w, "{}", i.inner_impl().print(use_absolute, cx));
|
||||||
if show_def_docs {
|
if show_def_docs {
|
||||||
for it in &i.inner_impl().items {
|
for it in &i.inner_impl().items {
|
||||||
@ -1566,14 +1569,11 @@ fn render_impl(
|
|||||||
write!(
|
write!(
|
||||||
w,
|
w,
|
||||||
"{}<h3 id=\"{}\" class=\"impl\"{}><code class=\"in-band\">{}</code>",
|
"{}<h3 id=\"{}\" class=\"impl\"{}><code class=\"in-band\">{}</code>",
|
||||||
details_str,
|
open_details(&mut close_tags),
|
||||||
id,
|
id,
|
||||||
aliases,
|
aliases,
|
||||||
i.inner_impl().print(false, cx)
|
i.inner_impl().print(false, cx)
|
||||||
);
|
);
|
||||||
if !impl_items.is_empty() || !default_impl_items.is_empty() {
|
|
||||||
close_tags.insert_str(0, "</details>");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
write!(w, "<a href=\"#{}\" class=\"anchor\"></a>", id);
|
write!(w, "<a href=\"#{}\" class=\"anchor\"></a>", id);
|
||||||
render_stability_since_raw(
|
render_stability_since_raw(
|
||||||
@ -1584,7 +1584,7 @@ fn render_impl(
|
|||||||
outer_const_version,
|
outer_const_version,
|
||||||
);
|
);
|
||||||
write_srclink(cx, &i.impl_item, w);
|
write_srclink(cx, &i.impl_item, w);
|
||||||
if impl_items.is_empty() && default_impl_items.is_empty() {
|
if !toggled {
|
||||||
w.write_str("</h3>");
|
w.write_str("</h3>");
|
||||||
} else {
|
} else {
|
||||||
w.write_str("</h3></summary>");
|
w.write_str("</h3></summary>");
|
||||||
@ -1613,7 +1613,7 @@ fn render_impl(
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if !impl_items.is_empty() || !default_impl_items.is_empty() {
|
if toggled {
|
||||||
w.write_str("<div class=\"impl-items\">");
|
w.write_str("<div class=\"impl-items\">");
|
||||||
w.push_buffer(default_impl_items);
|
w.push_buffer(default_impl_items);
|
||||||
if trait_.is_some() && !impl_items.is_empty() {
|
if trait_.is_some() && !impl_items.is_empty() {
|
||||||
|
Loading…
Reference in New Issue
Block a user