Skip to content

Commit f6f5bab

Browse files
committed
test new pattern
1 parent 2b84fc5 commit f6f5bab

File tree

2 files changed

+23
-23
lines changed

2 files changed

+23
-23
lines changed

src/traits.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,6 @@ where
209209
}
210210

211211
fn edges(&self) -> &crate::EdgeTable {
212-
todo!("can only trigger with with Box<&thing that impl TableAccess>");
213212
T::edges(self)
214213
}
215214
fn sites(&self) -> &crate::SiteTable {

tests/test_table_traits.rs

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,11 @@ impl IteratorOutput {
6363
}
6464
}
6565

66+
fn new_from_table_access_impl_syntax(access: impl tskit::TableAccess) -> Self
67+
{
68+
Self::new_from_table_access(&access)
69+
}
70+
6671
fn new_from_table_iteration<T>(iterator: &T) -> Self
6772
where
6873
T: tskit::TableIteration,
@@ -101,10 +106,6 @@ impl IteratorOutput {
101106
}
102107
}
103108

104-
struct TablesHolder<'tables> {
105-
tables: &'tables tskit::TableCollection,
106-
}
107-
108109
fn validate_output_from_tables(tables: tskit::TableCollection) {
109110
let tables_output = IteratorOutput::new_from_tables(&tables);
110111
let access_output = IteratorOutput::new_from_table_access(&tables);
@@ -116,6 +117,22 @@ fn validate_output_from_tables(tables: tskit::TableCollection) {
116117
assert_eq!(tables_output, dynamic_output);
117118
}
118119

120+
fn validate_output_from_table_ref(tables: tskit::TableCollection) {
121+
let tref = &tables;
122+
let tables_output = IteratorOutput::new_from_tables(tref);
123+
let access_output = IteratorOutput::new_from_table_access(tref);
124+
assert_eq!(tables_output, access_output);
125+
let impl_syntax_output = IteratorOutput::new_from_table_access_impl_syntax(tref);
126+
assert_eq!(tables_output, impl_syntax_output);
127+
let iteration_output = IteratorOutput::new_from_table_iteration(tref);
128+
assert_eq!(tables_output, iteration_output);
129+
let boxed = Box::new(tref);
130+
let dynamic_output = IteratorOutput::new_from_dyn(&boxed);
131+
assert_eq!(tables_output, dynamic_output);
132+
let impl_syntax_output = IteratorOutput::new_from_table_access_impl_syntax(&boxed);
133+
assert_eq!(tables_output, impl_syntax_output);
134+
}
135+
119136
fn validate_output_from_treeseq(treeseq: tskit::TreeSequence) {
120137
let treeseq_output = IteratorOutput::new_from_treeseq(&treeseq);
121138
let access_output = IteratorOutput::new_from_table_access(&treeseq);
@@ -154,25 +171,9 @@ fn test_traits_with_table_collection() {
154171
}
155172

156173
#[test]
157-
fn test_traits_with_table_collection_holder() {
174+
fn test_traits_with_table_collection_ref() {
158175
let tables = make_tables();
159-
let tref: &tskit::TableCollection = &tables;
160-
let tables_output = IteratorOutput::new_from_tables(tref);
161-
//let boxed = Box::new(tref);
162-
//let dynamic_output = IteratorOutput::new_from_dyn(&boxed);
163-
//assert_eq!(tables_output, dynamic_output);
164-
fn foo(_: impl tskit::TableIteration) {
165-
todo!("this compiles");
166-
167-
}
168-
fn foo2<T>(_: T) where T: tskit::TableIteration {
169-
todo!("this compiles");
170-
}
171-
foo(tref);
172-
foo2(tref);
173-
let h = TablesHolder{tables:tref};
174-
foo(h.tables);
175-
foo2(h.tables);
176+
validate_output_from_table_ref(tables)
176177
}
177178

178179
#[test]

0 commit comments

Comments
 (0)