Skip to content

Commit 00eba9d

Browse files
committed
doc: Fold inline methods from Deref
1 parent 0ca92de commit 00eba9d

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

src/librustdoc/html/render/mod.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1256,6 +1256,7 @@ fn render_assoc_items_inner(
12561256
let Some(v) = cache.impls.get(&it) else { return };
12571257
let (non_trait, traits): (Vec<_>, _) = v.iter().partition(|i| i.inner_impl().trait_.is_none());
12581258
if !non_trait.is_empty() {
1259+
let mut close_tags = String::new();
12591260
let mut tmp_buf = Buffer::html();
12601261
let (render_mode, id, class_html) = match what {
12611262
AssocItemRender::All => {
@@ -1266,6 +1267,8 @@ fn render_assoc_items_inner(
12661267
let id =
12671268
cx.derive_id(small_url_encode(format!("deref-methods-{:#}", type_.print(cx))));
12681269
let derived_id = cx.derive_id(&id);
1270+
tmp_buf.write_str("<details class=\"toggle implementors-toggle\" open><summary>");
1271+
close_tags.insert_str(0, "</details>");
12691272
write_impl_section_heading(
12701273
&mut tmp_buf,
12711274
&format!(
@@ -1275,6 +1278,7 @@ fn render_assoc_items_inner(
12751278
),
12761279
&id,
12771280
);
1281+
tmp_buf.write_str("</summary>");
12781282
if let Some(def_id) = type_.def_id(cx.cache()) {
12791283
cx.deref_id_map.insert(def_id, id);
12801284
}
@@ -1308,6 +1312,7 @@ fn render_assoc_items_inner(
13081312
impls_buf.into_inner()
13091313
)
13101314
.unwrap();
1315+
w.write_str(&close_tags).unwrap();
13111316
}
13121317
}
13131318

tests/rustdoc/deref/deref-slice-core.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
use core::ops::Deref;
77

88
//@ has 'deref_slice_core/struct.MyArray.html'
9-
//@ has '-' '//*[@id="deref-methods-%5BT%5D"]' 'Methods from Deref<Target = [T]>'
9+
//@ has '-' '//details/summary/h2[@id="deref-methods-%5BT%5D"]' 'Methods from Deref<Target = [T]>'
1010
//@ has '-' '//*[@class="impl-items"]//*[@id="method.len"]' 'pub fn len(&self)'
1111

1212
pub struct MyArray<T> {

0 commit comments

Comments
 (0)