Skip to content

Commit 4e163af

Browse files
authored
Rollup merge of rust-lang#107725 - GuillaumeGomez:turn-markdownwithtoc-into-struct, r=notriddle
Turn MarkdownWithToc into a struct with named fields Extracted the commit from rust-lang#107640. r? `@notriddle`
2 parents 7be6e6d + 3b494a4 commit 4e163af

File tree

2 files changed

+17
-10
lines changed

2 files changed

+17
-10
lines changed

src/librustdoc/html/markdown.rs

+9-9
Original file line numberDiff line numberDiff line change
@@ -102,14 +102,14 @@ pub struct Markdown<'a> {
102102
/// E.g. if `heading_offset: HeadingOffset::H2`, then `# something` renders an `<h2>`.
103103
pub heading_offset: HeadingOffset,
104104
}
105-
/// A tuple struct like `Markdown` that renders the markdown with a table of contents.
106-
pub(crate) struct MarkdownWithToc<'a>(
107-
pub(crate) &'a str,
108-
pub(crate) &'a mut IdMap,
109-
pub(crate) ErrorCodes,
110-
pub(crate) Edition,
111-
pub(crate) &'a Option<Playground>,
112-
);
105+
/// A struct like `Markdown` that renders the markdown with a table of contents.
106+
pub(crate) struct MarkdownWithToc<'a> {
107+
pub(crate) content: &'a str,
108+
pub(crate) ids: &'a mut IdMap,
109+
pub(crate) error_codes: ErrorCodes,
110+
pub(crate) edition: Edition,
111+
pub(crate) playground: &'a Option<Playground>,
112+
}
113113
/// A tuple struct like `Markdown` that renders the markdown escaping HTML tags
114114
/// and includes no paragraph tags.
115115
pub(crate) struct MarkdownItemInfo<'a>(pub(crate) &'a str, pub(crate) &'a mut IdMap);
@@ -1048,7 +1048,7 @@ impl Markdown<'_> {
10481048

10491049
impl MarkdownWithToc<'_> {
10501050
pub(crate) fn into_string(self) -> String {
1051-
let MarkdownWithToc(md, ids, codes, edition, playground) = self;
1051+
let MarkdownWithToc { content: md, ids, error_codes: codes, edition, playground } = self;
10521052

10531053
let p = Parser::new_ext(md, main_body_opts()).into_offset_iter();
10541054

src/librustdoc/markdown.rs

+8-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,14 @@ pub(crate) fn render<P: AsRef<Path>>(
7272
let mut ids = IdMap::new();
7373
let error_codes = ErrorCodes::from(options.unstable_features.is_nightly_build());
7474
let text = if !options.markdown_no_toc {
75-
MarkdownWithToc(text, &mut ids, error_codes, edition, &playground).into_string()
75+
MarkdownWithToc {
76+
content: text,
77+
ids: &mut ids,
78+
error_codes,
79+
edition,
80+
playground: &playground,
81+
}
82+
.into_string()
7683
} else {
7784
Markdown {
7885
content: text,

0 commit comments

Comments
 (0)