mirror of
https://github.com/dnlbauer/xdrfile.git
synced 2026-09-11 14:45:31 +00:00
Refactor frame to have desired semantics
This commit is contained in:
@@ -2,9 +2,9 @@ use crate::*;
|
||||
use std::rc::Rc;
|
||||
|
||||
fn into_iter_inner<T: Trajectory>(mut traj: T) -> TrajectoryIterator<T> {
|
||||
let num_atoms = traj.get_num_atoms();
|
||||
let num_atoms = traj.get_num_atoms().map(|n| n as usize);
|
||||
let frame = match &num_atoms {
|
||||
Ok(num_atoms) => Frame::with_capacity(*num_atoms),
|
||||
Ok(num_atoms) => Frame::with_len(*num_atoms),
|
||||
Err(_) => Frame::new(),
|
||||
};
|
||||
TrajectoryIterator {
|
||||
@@ -58,7 +58,7 @@ impl<T: Trajectory> TrajectoryIterator<T> {
|
||||
Some(item) => item,
|
||||
None => {
|
||||
// caller kept frame. Create new one
|
||||
self.item = Rc::new(Frame::with_capacity(num_atoms));
|
||||
self.item = Rc::new(Frame::with_len(num_atoms as usize));
|
||||
Rc::get_mut(&mut self.item).expect("Could not get mutable access to new Rc")
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user