WIP
This commit is contained in:
@@ -778,32 +778,6 @@ impl<NTY: ScalarOps> Events for EventsDim0<NTY> {
|
||||
Box::new(ret)
|
||||
}
|
||||
|
||||
fn move_into_fresh(&mut self, ts_end: u64) -> Box<dyn Events> {
|
||||
// TODO improve the search
|
||||
let n1 = self.tss.iter().take_while(|&&x| x <= ts_end).count();
|
||||
let tss = self.tss.drain(..n1).collect();
|
||||
let pulses = self.pulses.drain(..n1).collect();
|
||||
let values = self.values.drain(..n1).collect();
|
||||
let ret = Self { tss, pulses, values };
|
||||
Box::new(ret)
|
||||
}
|
||||
|
||||
fn move_into_existing(&mut self, tgt: &mut Box<dyn Events>, ts_end: u64) -> Result<(), ()> {
|
||||
// TODO as_any and as_any_mut are declared on unrealted traits. Simplify.
|
||||
if let Some(tgt) = tgt.as_mut().as_any_mut().downcast_mut::<Self>() {
|
||||
// TODO improve the search
|
||||
let n1 = self.tss.iter().take_while(|&&x| x <= ts_end).count();
|
||||
// TODO make it harder to forget new members when the struct may get modified in the future
|
||||
tgt.tss.extend(self.tss.drain(..n1));
|
||||
tgt.pulses.extend(self.pulses.drain(..n1));
|
||||
tgt.values.extend(self.values.drain(..n1));
|
||||
Ok(())
|
||||
} else {
|
||||
eprintln!("downcast to EventsDim0 FAILED");
|
||||
Err(())
|
||||
}
|
||||
}
|
||||
|
||||
fn new_empty(&self) -> Box<dyn Events> {
|
||||
Box::new(Self::empty())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user