Skip to content

Commit ed3ace5

Browse files
Merge pull request #12 from sscdotopen/master
idiomatic collect() in map.rs
2 parents b76c44d + 21523a2 commit ed3ace5

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/map.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ use super::{Variable, Relation};
55
pub fn map_into<T1: Ord, T2: Ord>(
66
input: &Variable<T1>,
77
output: &Variable<T2>,
8-
mut logic: impl FnMut(&T1)->T2) {
8+
logic: impl FnMut(&T1)->T2) {
99

10-
let mut results = Vec::new();
11-
let recent = input.recent.borrow();
12-
for tuple in recent.iter() {
13-
results.push(logic(tuple));
14-
}
10+
let results: Vec<T2> = input.recent
11+
.borrow()
12+
.iter()
13+
.map(logic)
14+
.collect();
1515

1616
output.insert(Relation::from_vec(results));
1717
}

0 commit comments

Comments
 (0)