Skip to content

Commit 0f4e4a0

Browse files
committed
rustdoc: Rename internal API fns to into_string
to avoid surprising listed in API guidelines.
1 parent 567ad74 commit 0f4e4a0

File tree

6 files changed

+19
-18
lines changed

6 files changed

+19
-18
lines changed

src/librustdoc/externalfiles.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,14 @@ impl ExternalHtml {
3737
let bc = format!(
3838
"{}{}",
3939
bc,
40-
Markdown(&m_bc, &[], id_map, codes, edition, playground).to_string()
40+
Markdown(&m_bc, &[], id_map, codes, edition, playground).into_string()
4141
);
4242
let ac = load_external_files(after_content, diag)?;
4343
let m_ac = load_external_files(md_after_content, diag)?;
4444
let ac = format!(
4545
"{}{}",
4646
ac,
47-
Markdown(&m_ac, &[], id_map, codes, edition, playground).to_string()
47+
Markdown(&m_ac, &[], id_map, codes, edition, playground).into_string()
4848
);
4949
Some(ExternalHtml { in_header: ih, before_content: bc, after_content: ac })
5050
}

src/librustdoc/html/markdown.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
//! let s = "My *markdown* _text_";
1414
//! let mut id_map = IdMap::new();
1515
//! let md = Markdown(s, &[], &mut id_map, ErrorCodes::Yes, Edition::Edition2015, &None);
16-
//! let html = md.to_string();
16+
//! let html = md.into_string();
1717
//! // ... something using html
1818
//! ```
1919
@@ -848,7 +848,7 @@ impl LangString {
848848
}
849849

850850
impl Markdown<'_> {
851-
pub fn to_string(self) -> String {
851+
pub fn into_string(self) -> String {
852852
let Markdown(md, links, mut ids, codes, edition, playground) = self;
853853

854854
// This is actually common enough to special-case
@@ -878,7 +878,7 @@ impl Markdown<'_> {
878878
}
879879

880880
impl MarkdownWithToc<'_> {
881-
pub fn to_string(self) -> String {
881+
pub fn into_string(self) -> String {
882882
let MarkdownWithToc(md, mut ids, codes, edition, playground) = self;
883883

884884
let p = Parser::new_ext(md, opts());
@@ -899,7 +899,7 @@ impl MarkdownWithToc<'_> {
899899
}
900900

901901
impl MarkdownHtml<'_> {
902-
pub fn to_string(self) -> String {
902+
pub fn into_string(self) -> String {
903903
let MarkdownHtml(md, mut ids, codes, edition, playground) = self;
904904

905905
// This is actually common enough to special-case
@@ -926,7 +926,7 @@ impl MarkdownHtml<'_> {
926926
}
927927

928928
impl MarkdownSummaryLine<'_> {
929-
pub fn to_string(self) -> String {
929+
pub fn into_string(self) -> String {
930930
let MarkdownSummaryLine(md, links) = self;
931931
// This is actually common enough to special-case
932932
if md.is_empty() {

src/librustdoc/html/markdown/tests.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ fn test_header() {
134134
fn t(input: &str, expect: &str) {
135135
let mut map = IdMap::new();
136136
let output =
137-
Markdown(input, &[], &mut map, ErrorCodes::Yes, DEFAULT_EDITION, &None).to_string();
137+
Markdown(input, &[], &mut map, ErrorCodes::Yes, DEFAULT_EDITION, &None).into_string();
138138
assert_eq!(output, expect, "original: {}", input);
139139
}
140140

@@ -166,7 +166,8 @@ fn test_header() {
166166
fn test_header_ids_multiple_blocks() {
167167
let mut map = IdMap::new();
168168
fn t(map: &mut IdMap, input: &str, expect: &str) {
169-
let output = Markdown(input, &[], map, ErrorCodes::Yes, DEFAULT_EDITION, &None).to_string();
169+
let output =
170+
Markdown(input, &[], map, ErrorCodes::Yes, DEFAULT_EDITION, &None).into_string();
170171
assert_eq!(output, expect, "original: {}", input);
171172
}
172173

@@ -228,7 +229,7 @@ fn test_markdown_html_escape() {
228229
fn t(input: &str, expect: &str) {
229230
let mut idmap = IdMap::new();
230231
let output =
231-
MarkdownHtml(input, &mut idmap, ErrorCodes::Yes, DEFAULT_EDITION, &None).to_string();
232+
MarkdownHtml(input, &mut idmap, ErrorCodes::Yes, DEFAULT_EDITION, &None).into_string();
232233
assert_eq!(output, expect, "original: {}", input);
233234
}
234235

src/librustdoc/html/render.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -1894,7 +1894,7 @@ fn render_markdown(
18941894
cx.shared.edition,
18951895
&cx.shared.playground
18961896
)
1897-
.to_string()
1897+
.into_string()
18981898
)
18991899
}
19001900

@@ -2184,7 +2184,7 @@ fn item_module(w: &mut Buffer, cx: &Context, item: &clean::Item, items: &[clean:
21842184
</tr>",
21852185
name = *myitem.name.as_ref().unwrap(),
21862186
stab_tags = stability_tags(myitem),
2187-
docs = MarkdownSummaryLine(doc_value, &myitem.links()).to_string(),
2187+
docs = MarkdownSummaryLine(doc_value, &myitem.links()).into_string(),
21882188
class = myitem.type_(),
21892189
add = add,
21902190
stab = stab.unwrap_or_else(String::new),
@@ -2277,7 +2277,7 @@ fn short_stability(item: &clean::Item, cx: &Context) -> Vec<String> {
22772277
cx.shared.edition,
22782278
&cx.shared.playground,
22792279
);
2280-
message.push_str(&format!(": {}", html.to_string()));
2280+
message.push_str(&format!(": {}", html.into_string()));
22812281
}
22822282
stability.push(format!(
22832283
"<div class='stab deprecated'><span class='emoji'>👎</span> {}</div>",
@@ -2331,7 +2331,7 @@ fn short_stability(item: &clean::Item, cx: &Context) -> Vec<String> {
23312331
cx.shared.edition,
23322332
&cx.shared.playground,
23332333
)
2334-
.to_string()
2334+
.into_string()
23352335
);
23362336
}
23372337

@@ -3631,7 +3631,7 @@ fn render_impl(
36313631
cx.shared.edition,
36323632
&cx.shared.playground
36333633
)
3634-
.to_string()
3634+
.into_string()
36353635
);
36363636
}
36373637
}

src/librustdoc/markdown.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,9 @@ pub fn render<P: AsRef<Path>>(
6868
let mut ids = IdMap::new();
6969
let error_codes = ErrorCodes::from(UnstableFeatures::from_environment().is_nightly_build());
7070
let text = if !options.markdown_no_toc {
71-
MarkdownWithToc(text, &mut ids, error_codes, edition, &playground).to_string()
71+
MarkdownWithToc(text, &mut ids, error_codes, edition, &playground).into_string()
7272
} else {
73-
Markdown(text, &[], &mut ids, error_codes, edition, &playground).to_string()
73+
Markdown(text, &[], &mut ids, error_codes, edition, &playground).into_string()
7474
};
7575

7676
let err = write!(

src/tools/error_index_generator/main.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ impl Formatter for HTMLFormatter {
127127
DEFAULT_EDITION,
128128
&Some(playground)
129129
)
130-
.to_string()
130+
.into_string()
131131
)?
132132
}
133133
None => write!(output, "<p>No description.</p>\n")?,

0 commit comments

Comments
 (0)