From 3d5f1bc2c1033e4c2c3f7bc17073ebe7cebad66c Mon Sep 17 00:00:00 2001 From: Justus Winter Date: Tue, 7 May 2019 18:23:26 +0200 Subject: openpgp-ffi, ffi: Reword. --- ffi/tests/c-tests.rs | 13 ++++--------- openpgp-ffi/tests/c-tests.rs | 13 ++++--------- 2 files changed, 8 insertions(+), 18 deletions(-) diff --git a/ffi/tests/c-tests.rs b/ffi/tests/c-tests.rs index a5bd1f67..986468fd 100644 --- a/ffi/tests/c-tests.rs +++ b/ffi/tests/c-tests.rs @@ -292,9 +292,8 @@ fn wrap_with_main(test: &mut Vec, offset: usize) { } test.insert(last_include + 2, format!("#line {}", last_include + offset + if needs_wrapping {1} else {0})); - let last = test.len(); if needs_wrapping { - test.insert(last, "}".into()); + test.push("}".into()); } test.insert(0, "#include ".into()); test.insert(0, "#include ".into()); @@ -304,13 +303,9 @@ fn wrap_with_main(test: &mut Vec, offset: usize) { /// Checks if the code contains a main function. fn has_main(test: &mut Vec) -> bool { - for line in test { - if line.contains("main()") || line.contains("main ()") + test.iter().any(|line| { + line.contains("main()") || line.contains("main ()") || line.contains("main(int argc, char **argv)") || line.contains("main (int argc, char **argv)") - { - return true; - } - } - false + }) } diff --git a/openpgp-ffi/tests/c-tests.rs b/openpgp-ffi/tests/c-tests.rs index 06ab21a5..68bf9472 100644 --- a/openpgp-ffi/tests/c-tests.rs +++ b/openpgp-ffi/tests/c-tests.rs @@ -291,9 +291,8 @@ fn wrap_with_main(test: &mut Vec, offset: usize) { } test.insert(last_include + 2, format!("#line {}", last_include + offset + if needs_wrapping {1} else {0})); - let last = test.len(); if needs_wrapping { - test.insert(last, "}".into()); + test.push("}".into()); } test.insert(0, "#include ".into()); test.insert(0, "#include ".into()); @@ -303,13 +302,9 @@ fn wrap_with_main(test: &mut Vec, offset: usize) { /// Checks if the code contains a main function. fn has_main(test: &mut Vec) -> bool { - for line in test { - if line.contains("main()") || line.contains("main ()") + test.iter().any(|line| { + line.contains("main()") || line.contains("main ()") || line.contains("main(int argc, char **argv)") || line.contains("main (int argc, char **argv)") - { - return true; - } - } - false + }) } -- cgit v1.2.3