Skip to content

Commit d3cb170

Browse files
committed
Better
1 parent 0570bd0 commit d3cb170

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

src/lib.rs

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -103,16 +103,15 @@ impl Instrumentor {
103103
version: &str,
104104
file_path: &PathBuf,
105105
) -> InstrumentationVisitor {
106-
let mut instrumentations = self
106+
let instrumentations = self
107107
.instrumentations
108108
.iter()
109109
.filter(|instr| instr.matches(module_name, version, file_path))
110110
.cloned()
111-
.collect::<Vec<_>>();
112-
113-
for instr in &mut instrumentations {
114-
instr.set_module_version(version);
115-
}
111+
.map(|mut i| {
112+
i.set_module_version(version);
113+
i
114+
});
116115

117116
InstrumentationVisitor::new(instrumentations, &self.dc_module)
118117
}
@@ -125,10 +124,12 @@ pub struct InstrumentationVisitor {
125124
}
126125

127126
impl InstrumentationVisitor {
128-
fn new(instrumentations: Vec<Instrumentation>, dc_module: &str) -> Self
129-
where {
127+
fn new<I>(instrumentations: I, dc_module: &str) -> Self
128+
where
129+
I: Iterator<Item = Instrumentation>,
130+
{
130131
Self {
131-
instrumentations,
132+
instrumentations: instrumentations.collect(),
132133
dc_module: dc_module.to_string(),
133134
}
134135
}

0 commit comments

Comments
 (0)