mirror of
https://github.com/dnlbauer/xdrfile.git
synced 2026-09-10 14:15:31 +00:00
Deref rather than clone in Frame::filter_coords()
This commit is contained in:
@@ -40,14 +40,13 @@ impl Frame {
|
||||
}
|
||||
|
||||
/// 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
|
||||
.coords
|
||||
.iter()
|
||||
.map(|elem| elem.clone())
|
||||
.enumerate()
|
||||
.filter(|&(i, _)| indeces.contains(&i))
|
||||
.map(|(_, elem)| elem)
|
||||
.filter(|(i, _)| indices.contains(i))
|
||||
.map(|(_, elem)| *elem)
|
||||
.collect();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user