mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-26 04:53:34 +00:00
Simplify fixture parsing
This commit is contained in:
parent
5dcd9fdf5e
commit
c445c72eb3
1 changed files with 8 additions and 21 deletions
|
@ -188,29 +188,16 @@ pub fn parse_fixture(fixture: &str) -> Vec<FixtureEntry> {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
let mut res = Vec::new();
|
let mut res: Vec<FixtureEntry> = Vec::new();
|
||||||
let mut meta = None;
|
for line in lines.by_ref() {
|
||||||
loop {
|
if line.starts_with("//-") {
|
||||||
let mut next_meta = None;
|
let meta = line["//-".len()..].trim().to_string();
|
||||||
let mut text = String::new();
|
res.push(FixtureEntry { meta, text: String::new() })
|
||||||
for line in lines.by_ref() {
|
} else if let Some(entry) = res.last_mut() {
|
||||||
if line.starts_with("//-") {
|
entry.text.push_str(line);
|
||||||
next_meta = Some(line["//-".len()..].trim().to_string());
|
entry.text.push('\n');
|
||||||
break;
|
|
||||||
}
|
|
||||||
text.push_str(line);
|
|
||||||
text.push('\n');
|
|
||||||
}
|
|
||||||
|
|
||||||
if let Some(meta) = meta {
|
|
||||||
res.push(FixtureEntry { meta, text });
|
|
||||||
}
|
|
||||||
meta = next_meta;
|
|
||||||
if meta.is_none() {
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
res
|
res
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue