From a40b715ce1cae4db1b4c3b4c383ee7517d4202c4 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sun, 4 Feb 2018 13:39:24 +0300 Subject: G: unsafe impl & trait --- tools/src/bin/collect-tests.rs | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'tools/src/bin') diff --git a/tools/src/bin/collect-tests.rs b/tools/src/bin/collect-tests.rs index df9d2db81..9a84d92fc 100644 --- a/tools/src/bin/collect-tests.rs +++ b/tools/src/bin/collect-tests.rs @@ -79,16 +79,19 @@ fn collect_tests(s: &str) -> Vec { .map(str::trim_left) .group_by(|line| line.starts_with(prefix)); - for (is_comment, block) in comment_blocks.into_iter() { + 'outer: for (is_comment, block) in comment_blocks.into_iter() { if !is_comment { continue; } let mut block = block.map(|line| &line[prefix.len()..]); - let first = block.next().unwrap(); - if !first.starts_with("test ") { - continue; - } - let name = first["test ".len()..].to_string(); + + let name = loop { + match block.next() { + Some(line) if line.starts_with("test ") => break line["test ".len()..].to_string(), + Some(_) => (), + None => continue 'outer, + } + }; let text: String = itertools::join(block.chain(::std::iter::once("")), "\n"); assert!(!text.trim().is_empty() && text.ends_with("\n")); res.push(Test { name, text }) -- cgit v1.2.3