提交 4dfe7a16 编写于 作者: B bors

Auto merge of #27410 - Gankro:meta, r=alexcrichton

Fixes #27404
......@@ -29,13 +29,14 @@
/// Separate any lines at the start of the file that begin with `%`.
fn extract_leading_metadata<'a>(s: &'a str) -> (Vec<&'a str>, &'a str) {
let mut metadata = Vec::new();
let mut count = 0;
for line in s.lines() {
if line.starts_with("%") {
// remove %<whitespace>
metadata.push(line[1..].trim_left())
metadata.push(line[1..].trim_left());
count += line.len() + 1;
} else {
let line_start_byte = s.find(line).unwrap();
return (metadata, &s[line_start_byte..]);
return (metadata, &s[count..]);
}
}
// if we're here, then all lines were metadata % lines.
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册