diff options
| author | bors <bors@rust-lang.org> | 2022-04-12 22:56:06 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2022-04-12 22:56:06 +0000 |
| commit | f6cef572d6d75a3b7dea5f496d3bd981986e94ca (patch) | |
| tree | 6338fa6a67d8b8db095ac6d8747f7eb7e6ccb4de | |
| parent | 52ca603da73ae9eaddf96f77953b33ad8c47cc8e (diff) | |
| parent | ab3ab4de0b0e39f64737c9414213fd66e638cf78 (diff) | |
| download | rust-f6cef572d6d75a3b7dea5f496d3bd981986e94ca.tar.gz rust-f6cef572d6d75a3b7dea5f496d3bd981986e94ca.zip | |
Auto merge of #95905 - vacuus:markdown-render, r=GuillaumeGomez
rustdoc: Reduce allocations in a `markdown` function Not `html::markdown` this time, just `markdown`, haha.
| -rw-r--r-- | src/librustdoc/markdown.rs | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/librustdoc/markdown.rs b/src/librustdoc/markdown.rs index a1f92afad46..62e42b783e9 100644 --- a/src/librustdoc/markdown.rs +++ b/src/librustdoc/markdown.rs @@ -1,3 +1,4 @@ +use std::fmt::Write as _; use std::fs::{create_dir_all, read_to_string, File}; use std::io::prelude::*; use std::path::Path; @@ -51,8 +52,8 @@ crate fn render<P: AsRef<Path>>( let mut css = String::new(); for name in &options.markdown_css { - let s = format!("<link rel=\"stylesheet\" type=\"text/css\" href=\"{name}\">\n"); - css.push_str(&s) + write!(css, r#"<link rel="stylesheet" type="text/css" href="{name}">"#) + .expect("Writing to a String can't fail"); } let input_str = read_to_string(input).map_err(|err| format!("{}: {}", input.display(), err))?; |
