Skip to content

Commit

Permalink
Auto merge of rust-lang#95905 - vacuus:markdown-render, r=GuillaumeGomez
Browse files Browse the repository at this point in the history
rustdoc: Reduce allocations in a `markdown` function

Not `html::markdown` this time, just `markdown`, haha.
  • Loading branch information
bors committed Apr 12, 2022
2 parents 52ca603 + ab3ab4d commit f6cef57
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/librustdoc/markdown.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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))?;
Expand Down

0 comments on commit f6cef57

Please sign in to comment.