Deref rather than clone in Frame::filter_coords()

This commit is contained in:
Josh Mitchell
2020-11-16 14:01:42 +11:00
parent 5b7247962e
commit 49f77c672a

View File

@@ -40,14 +40,13 @@ impl Frame {
} }
/// Filters the frame by removing all atoms not matching the given indeces. /// Filters the frame by removing all atoms not matching the given indeces.
pub fn filter_coords(self: &mut Frame, indeces: &[usize]) { pub fn filter_coords(self: &mut Frame, indices: &[usize]) {
self.coords = self self.coords = self
.coords .coords
.iter() .iter()
.map(|elem| elem.clone())
.enumerate() .enumerate()
.filter(|&(i, _)| indeces.contains(&i)) .filter(|(i, _)| indices.contains(i))
.map(|(_, elem)| elem) .map(|(_, elem)| *elem)
.collect(); .collect();
} }