diff --git a/src/iterator.rs b/src/iterator.rs index 71b3657..540a950 100644 --- a/src/iterator.rs +++ b/src/iterator.rs @@ -11,7 +11,6 @@ fn into_iter_inner(mut traj: T) -> TrajectoryIterator { trajectory: traj, item: Rc::new(frame), has_error: false, - num_atoms, } } @@ -42,14 +41,14 @@ pub struct TrajectoryIterator { trajectory: T, item: Rc, has_error: bool, - num_atoms: Result, } impl TrajectoryIterator { /// Inner function for `next()` to seperate error handling from iteration logic fn next_inner(&mut self) -> ::Item { // If we couldn't read the number of frames when we called into_iter, return that error now - let num_atoms = match &self.num_atoms { + // It's OK to do this every frame because the result is cached by Trajectory + let num_atoms = match &self.trajectory.get_num_atoms() { &Ok(n) => n, Err(e) => Err(Error::CheckNAtomsDuringIter(Box::new(e.clone())))?, };