diff --git a/src/population_table.rs b/src/population_table.rs
index e5c06d4f3..ab462cd50 100644
--- a/src/population_table.rs
+++ b/src/population_table.rs
@@ -24,7 +24,7 @@ fn make_population_table_row(table: &PopulationTable, pos: tsk_id_t) -> Option
Option
=
- crate::table_iterator::TableIterator<&'a PopulationTable<'a>>;
-pub(crate) type PopulationTableIterator<'a> =
- crate::table_iterator::TableIterator>;
+ crate::table_iterator::TableIterator<&'a PopulationTable>;
+pub(crate) type PopulationTableIterator<'a> = crate::table_iterator::TableIterator;
impl<'a> Iterator for PopulationTableRefIterator<'a> {
type Item = PopulationTableRow;
@@ -65,25 +64,32 @@ impl<'a> Iterator for PopulationTableIterator<'a> {
/// These are not created directly.
/// Instead, use [`TableAccess::populations`](crate::TableAccess::populations)
/// to get a reference to an existing population table;
-pub struct PopulationTable<'a> {
- table_: &'a ll_bindings::tsk_population_table_t,
+pub struct PopulationTable {
+ pub(crate) table_: *const ll_bindings::tsk_population_table_t,
}
-impl<'a> PopulationTable<'a> {
- pub(crate) fn new_from_table(mutations: &'a ll_bindings::tsk_population_table_t) -> Self {
- PopulationTable { table_: mutations }
+impl PopulationTable {
+ fn ll_table_ref(&self) -> &ll_bindings::tsk_population_table_t {
+ unsafe { &(*self.table_) }
+ }
+
+ pub(crate) fn new_from_table(populations: *const ll_bindings::tsk_population_table_t) -> Self {
+ // assert!(!populations.is_null());
+ PopulationTable {
+ table_: populations,
+ }
}
/// Return the number of rows.
- pub fn num_rows(&'a self) -> SizeType {
- self.table_.num_rows.into()
+ pub fn num_rows(&self) -> SizeType {
+ self.ll_table_ref().num_rows.into()
}
pub fn metadata(
- &'a self,
+ &self,
row: PopulationId,
) -> Result