Skip to content

Commit 52735d6

Browse files
committed
use IntoIterator for the add_flags methods
1 parent 071373d commit 52735d6

File tree

2 files changed

+11
-10
lines changed

2 files changed

+11
-10
lines changed

crates/intrinsic-test/src/arm/compile.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,16 @@ pub fn build_cpp_compilation(config: &ProcessedCli) -> Option<CppCompilation> {
66

77
// -ffp-contract=off emulates Rust's approach of not fusing separate mul-add operations
88
let mut command = CompilationCommandBuilder::new()
9-
.add_arch_flags(vec!["armv8.6-a", "crypto", "crc", "dotprod", "fp16"])
9+
.add_arch_flags(["armv8.6-a", "crypto", "crc", "dotprod", "fp16"])
1010
.set_compiler(cpp_compiler)
1111
.set_target(&config.target)
1212
.set_opt_level("2")
1313
.set_cxx_toolchain_dir(config.cxx_toolchain_dir.as_deref())
1414
.set_project_root("c_programs")
15-
.add_extra_flags(vec!["-ffp-contract=off", "-Wno-narrowing"]);
15+
.add_extra_flags(["-ffp-contract=off", "-Wno-narrowing"]);
1616

1717
if !config.target.contains("v7") {
18-
command = command.add_arch_flags(vec!["faminmax", "lut", "sha3"]);
18+
command = command.add_arch_flags(["faminmax", "lut", "sha3"]);
1919
}
2020

2121
if !cpp_compiler.contains("clang") {

crates/intrinsic-test/src/common/compile_c.rs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@ impl CompilationCommandBuilder {
3737
self
3838
}
3939

40-
pub fn add_arch_flags(mut self, flags: Vec<&str>) -> Self {
41-
let mut new_arch_flags = flags.into_iter().map(|v| v.to_string()).collect();
42-
self.arch_flags.append(&mut new_arch_flags);
40+
pub fn add_arch_flags<'a>(mut self, flags: impl IntoIterator<Item = &'a str>) -> Self {
41+
self.arch_flags
42+
.extend(flags.into_iter().map(|s| s.to_owned()));
4343

4444
self
4545
}
@@ -55,14 +55,15 @@ impl CompilationCommandBuilder {
5555
self
5656
}
5757

58-
pub fn add_extra_flags(mut self, flags: Vec<&str>) -> Self {
59-
let mut flags: Vec<String> = flags.into_iter().map(|f| f.to_string()).collect();
60-
self.extra_flags.append(&mut flags);
58+
pub fn add_extra_flags<'a>(mut self, flags: impl IntoIterator<Item = &'a str>) -> Self {
59+
self.extra_flags
60+
.extend(flags.into_iter().map(|s| s.to_owned()));
61+
6162
self
6263
}
6364

6465
pub fn add_extra_flag(self, flag: &str) -> Self {
65-
self.add_extra_flags(vec![flag])
66+
self.add_extra_flags([flag])
6667
}
6768
}
6869

0 commit comments

Comments
 (0)