Skip to content

Commit 81ab000

Browse files
committed
fix tests, fill in impl details
1 parent 966a6b3 commit 81ab000

File tree

2 files changed

+41
-13
lines changed

2 files changed

+41
-13
lines changed

src/traits.rs

+28-1
Original file line numberDiff line numberDiff line change
@@ -133,14 +133,41 @@ pub trait TableIteration: TableAccess {
133133
fn edges_iter(&self) -> impl Iterator<Item = crate::EdgeTableRow> + '_ {
134134
self.edges().iter()
135135
}
136+
fn nodes_iter(&self) -> impl Iterator<Item = crate::NodeTableRow> + '_ {
137+
self.nodes().iter()
138+
}
139+
fn sites_iter(&self) -> impl Iterator<Item = crate::SiteTableRow> + '_ {
140+
self.sites().iter()
141+
}
142+
fn mutations_iter(&self) -> impl Iterator<Item = crate::MutationTableRow> + '_ {
143+
self.mutations().iter()
144+
}
145+
fn migrations_iter(&self) -> impl Iterator<Item = crate::MigrationTableRow> + '_ {
146+
self.migrations().iter()
147+
}
148+
fn populations_iter(&self) -> impl Iterator<Item = crate::PopulationTableRow> + '_ {
149+
self.populations().iter()
150+
}
136151
}
137152

138153
pub trait ObjectSafeTableIteration: TableAccess {
139154
fn edges_iter(&self) -> Box<dyn Iterator<Item = crate::EdgeTableRow> + '_> {
140155
Box::new(self.edges().iter())
141156
}
157+
fn nodes_iter(&self) -> Box<dyn Iterator<Item = crate::NodeTableRow> + '_> {
158+
Box::new(self.nodes().iter())
159+
}
160+
fn sites_iter(&self) -> Box<dyn Iterator<Item = crate::SiteTableRow> + '_> {
161+
Box::new(self.sites().iter())
162+
}
163+
fn mutations_iter(&self) -> Box<dyn Iterator<Item = crate::MutationTableRow> + '_> {
164+
Box::new(self.mutations().iter())
165+
}
166+
fn migrations_iter(&self) -> Box<dyn Iterator<Item = crate::MigrationTableRow> + '_> {
167+
Box::new(self.migrations().iter())
168+
}
142169
fn populations_iter(&self) -> Box<dyn Iterator<Item = crate::PopulationTableRow> + '_> {
143-
Box::new(self.populations().iter())
170+
Box::new(Box::new(self.populations().iter()))
144171
}
145172
}
146173

tests/test_table_traits.rs

+13-12
Original file line numberDiff line numberDiff line change
@@ -73,12 +73,12 @@ impl IteratorOutput {
7373
where
7474
T: TableIteration,
7575
{
76-
let edges = iterator.edges().iter().collect::<Vec<_>>();
77-
let nodes = iterator.nodes().iter().collect::<Vec<_>>();
78-
let sites = iterator.sites().iter().collect::<Vec<_>>();
79-
let mutations = iterator.mutations().iter().collect::<Vec<_>>();
80-
let populations = iterator.populations().iter().collect::<Vec<_>>();
81-
let migrations = iterator.migrations().iter().collect::<Vec<_>>();
76+
let edges = iterator.edges_iter().collect::<Vec<_>>();
77+
let nodes = iterator.nodes_iter().collect::<Vec<_>>();
78+
let sites = iterator.sites_iter().collect::<Vec<_>>();
79+
let mutations = iterator.mutations_iter().collect::<Vec<_>>();
80+
let populations = iterator.populations_iter().collect::<Vec<_>>();
81+
let migrations = iterator.migrations_iter().collect::<Vec<_>>();
8282
Self {
8383
edges,
8484
nodes,
@@ -90,12 +90,13 @@ impl IteratorOutput {
9090
}
9191

9292
fn new_from_dyn(dynamic: &dyn tskit::ObjectSafeTableIteration) -> Self {
93-
let edges = dynamic.edges().iter().collect::<Vec<_>>();
94-
let nodes = dynamic.nodes().iter().collect::<Vec<_>>();
95-
let sites = dynamic.sites().iter().collect::<Vec<_>>();
96-
let mutations = dynamic.mutations().iter().collect::<Vec<_>>();
97-
let populations = dynamic.populations().iter().collect::<Vec<_>>();
98-
let migrations = dynamic.migrations().iter().collect::<Vec<_>>();
93+
let edges_iter: Box<dyn Iterator<Item = tskit::EdgeTableRow> + '_> = dynamic.edges_iter();
94+
let edges = edges_iter.collect::<Vec<_>>();
95+
let nodes = dynamic.nodes_iter().collect::<Vec<_>>();
96+
let sites = dynamic.sites_iter().collect::<Vec<_>>();
97+
let mutations = dynamic.mutations_iter().collect::<Vec<_>>();
98+
let populations = dynamic.populations_iter().collect::<Vec<_>>();
99+
let migrations = dynamic.migrations_iter().collect::<Vec<_>>();
99100
Self {
100101
edges,
101102
nodes,

0 commit comments

Comments
 (0)