Skip to content

Commit 0c2e703

Browse files
bors[bot]matklad
andauthored
Merge #2952
2952: Simplify fixture parsing r=matklad a=matklad Co-authored-by: Aleksey Kladov <[email protected]>
2 parents 5dcd9fd + c445c72 commit 0c2e703

File tree

1 file changed

+8
-21
lines changed

1 file changed

+8
-21
lines changed

crates/test_utils/src/lib.rs

Lines changed: 8 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -188,29 +188,16 @@ pub fn parse_fixture(fixture: &str) -> Vec<FixtureEntry> {
188188
}
189189
});
190190

191-
let mut res = Vec::new();
192-
let mut meta = None;
193-
loop {
194-
let mut next_meta = None;
195-
let mut text = String::new();
196-
for line in lines.by_ref() {
197-
if line.starts_with("//-") {
198-
next_meta = Some(line["//-".len()..].trim().to_string());
199-
break;
200-
}
201-
text.push_str(line);
202-
text.push('\n');
203-
}
204-
205-
if let Some(meta) = meta {
206-
res.push(FixtureEntry { meta, text });
207-
}
208-
meta = next_meta;
209-
if meta.is_none() {
210-
break;
191+
let mut res: Vec<FixtureEntry> = Vec::new();
192+
for line in lines.by_ref() {
193+
if line.starts_with("//-") {
194+
let meta = line["//-".len()..].trim().to_string();
195+
res.push(FixtureEntry { meta, text: String::new() })
196+
} else if let Some(entry) = res.last_mut() {
197+
entry.text.push_str(line);
198+
entry.text.push('\n');
211199
}
212200
}
213-
214201
res
215202
}
216203

0 commit comments

Comments
 (0)