@@ -63,6 +63,11 @@ impl IteratorOutput {
63
63
}
64
64
}
65
65
66
+ fn new_from_table_access_impl_syntax ( access : impl tskit:: TableAccess ) -> Self
67
+ {
68
+ Self :: new_from_table_access ( & access)
69
+ }
70
+
66
71
fn new_from_table_iteration < T > ( iterator : & T ) -> Self
67
72
where
68
73
T : tskit:: TableIteration ,
@@ -101,10 +106,6 @@ impl IteratorOutput {
101
106
}
102
107
}
103
108
104
- struct TablesHolder < ' tables > {
105
- tables : & ' tables tskit:: TableCollection ,
106
- }
107
-
108
109
fn validate_output_from_tables ( tables : tskit:: TableCollection ) {
109
110
let tables_output = IteratorOutput :: new_from_tables ( & tables) ;
110
111
let access_output = IteratorOutput :: new_from_table_access ( & tables) ;
@@ -116,6 +117,22 @@ fn validate_output_from_tables(tables: tskit::TableCollection) {
116
117
assert_eq ! ( tables_output, dynamic_output) ;
117
118
}
118
119
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
+
119
136
fn validate_output_from_treeseq ( treeseq : tskit:: TreeSequence ) {
120
137
let treeseq_output = IteratorOutput :: new_from_treeseq ( & treeseq) ;
121
138
let access_output = IteratorOutput :: new_from_table_access ( & treeseq) ;
@@ -154,25 +171,9 @@ fn test_traits_with_table_collection() {
154
171
}
155
172
156
173
#[ test]
157
- fn test_traits_with_table_collection_holder ( ) {
174
+ fn test_traits_with_table_collection_ref ( ) {
158
175
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)
176
177
}
177
178
178
179
#[ test]
0 commit comments