Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/edge_table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ fn make_edge_table_row(table: &EdgeTable, pos: tsk_id_t) -> Option<EdgeTableRow>
}
}

pub type EdgeTableRefIterator<'a> = crate::table_iterator::TableIterator<&'a EdgeTable<'a>>;
pub type EdgeTableIterator<'a> = crate::table_iterator::TableIterator<EdgeTable<'a>>;
pub(crate) type EdgeTableRefIterator<'a> = crate::table_iterator::TableIterator<&'a EdgeTable<'a>>;
pub(crate) type EdgeTableIterator<'a> = crate::table_iterator::TableIterator<EdgeTable<'a>>;

impl<'a> Iterator for EdgeTableRefIterator<'a> {
type Item = EdgeTableRow;
Expand Down Expand Up @@ -133,7 +133,7 @@ impl<'a> EdgeTable<'a> {
/// Return an iterator over rows of the table.
/// The value of the iterator is [`EdgeTableRow`].
///
pub fn iter(&self) -> EdgeTableRefIterator {
pub fn iter(&self) -> impl Iterator<Item = EdgeTableRow> + '_ {
crate::table_iterator::make_table_iterator::<&EdgeTable<'a>>(self)
}

Expand Down
7 changes: 4 additions & 3 deletions src/individual_table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,10 @@ fn make_individual_table_row(table: &IndividualTable, pos: tsk_id_t) -> Option<I
}
}

pub type IndividualTableRefIterator<'a> =
pub(crate) type IndividualTableRefIterator<'a> =
crate::table_iterator::TableIterator<&'a IndividualTable<'a>>;
pub type IndividualTableIterator<'a> = crate::table_iterator::TableIterator<IndividualTable<'a>>;
pub(crate) type IndividualTableIterator<'a> =
crate::table_iterator::TableIterator<IndividualTable<'a>>;

impl<'a> Iterator for IndividualTableRefIterator<'a> {
type Item = IndividualTableRow;
Expand Down Expand Up @@ -163,7 +164,7 @@ impl<'a> IndividualTable<'a> {
/// Return an iterator over rows of the table.
/// The value of the iterator is [`IndividualTableRow`].
///
pub fn iter(&self) -> IndividualTableRefIterator {
pub fn iter(&self) -> impl Iterator<Item = IndividualTableRow> + '_ {
crate::table_iterator::make_table_iterator::<&IndividualTable<'a>>(self)
}

Expand Down
7 changes: 4 additions & 3 deletions src/migration_table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,10 @@ fn make_migration_table_row(table: &MigrationTable, pos: tsk_id_t) -> Option<Mig
}
}

pub type MigrationTableRefIterator<'a> =
pub(crate) type MigrationTableRefIterator<'a> =
crate::table_iterator::TableIterator<&'a MigrationTable<'a>>;
pub type MigrationTableIterator<'a> = crate::table_iterator::TableIterator<MigrationTable<'a>>;
pub(crate) type MigrationTableIterator<'a> =
crate::table_iterator::TableIterator<MigrationTable<'a>>;

impl<'a> Iterator for MigrationTableRefIterator<'a> {
type Item = MigrationTableRow;
Expand Down Expand Up @@ -172,7 +173,7 @@ impl<'a> MigrationTable<'a> {

/// Return an iterator over rows of the table.
/// The value of the iterator is [`MigrationTableRow`].
pub fn iter(&self) -> MigrationTableRefIterator {
pub fn iter(&self) -> impl Iterator<Item = MigrationTableRow> + '_ {
crate::table_iterator::make_table_iterator::<&MigrationTable<'a>>(self)
}

Expand Down
7 changes: 4 additions & 3 deletions src/mutation_table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,9 @@ fn make_mutation_table_row(table: &MutationTable, pos: tsk_id_t) -> Option<Mutat
None
}
}
pub type MutationTableRefIterator<'a> = crate::table_iterator::TableIterator<&'a MutationTable<'a>>;
pub type MutationTableIterator<'a> = crate::table_iterator::TableIterator<MutationTable<'a>>;
pub(crate) type MutationTableRefIterator<'a> =
crate::table_iterator::TableIterator<&'a MutationTable<'a>>;
pub(crate) type MutationTableIterator<'a> = crate::table_iterator::TableIterator<MutationTable<'a>>;

impl<'a> Iterator for MutationTableRefIterator<'a> {
type Item = MutationTableRow;
Expand Down Expand Up @@ -163,7 +164,7 @@ impl<'a> MutationTable<'a> {

/// Return an iterator over rows of the table.
/// The value of the iterator is [`MutationTableRow`].
pub fn iter(&self) -> MutationTableRefIterator {
pub fn iter(&self) -> impl Iterator<Item = MutationTableRow> + '_ {
crate::table_iterator::make_table_iterator::<&MutationTable<'a>>(self)
}

Expand Down
6 changes: 3 additions & 3 deletions src/node_table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ fn make_node_table_row(table: &NodeTable, pos: tsk_id_t) -> Option<NodeTableRow>
}
}

pub type NodeTableRefIterator<'a> = crate::table_iterator::TableIterator<&'a NodeTable<'a>>;
pub type NodeTableIterator<'a> = crate::table_iterator::TableIterator<NodeTable<'a>>;
pub(crate) type NodeTableRefIterator<'a> = crate::table_iterator::TableIterator<&'a NodeTable<'a>>;
pub(crate) type NodeTableIterator<'a> = crate::table_iterator::TableIterator<NodeTable<'a>>;

impl<'a> Iterator for NodeTableRefIterator<'a> {
type Item = NodeTableRow;
Expand Down Expand Up @@ -169,7 +169,7 @@ impl<'a> NodeTable<'a> {

/// Return an iterator over rows of the table.
/// The value of the iterator is [`NodeTableRow`].
pub fn iter(&self) -> NodeTableRefIterator {
pub fn iter(&self) -> impl Iterator<Item = NodeTableRow> + '_ {
crate::table_iterator::make_table_iterator::<&NodeTable<'a>>(self)
}

Expand Down
7 changes: 4 additions & 3 deletions src/population_table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,10 @@ fn make_population_table_row(table: &PopulationTable, pos: tsk_id_t) -> Option<P
}
}

pub type PopulationTableRefIterator<'a> =
pub(crate) type PopulationTableRefIterator<'a> =
crate::table_iterator::TableIterator<&'a PopulationTable<'a>>;
pub type PopulationTableIterator<'a> = crate::table_iterator::TableIterator<PopulationTable<'a>>;
pub(crate) type PopulationTableIterator<'a> =
crate::table_iterator::TableIterator<PopulationTable<'a>>;

impl<'a> Iterator for PopulationTableRefIterator<'a> {
type Item = PopulationTableRow;
Expand Down Expand Up @@ -82,7 +83,7 @@ impl<'a> PopulationTable<'a> {

/// Return an iterator over rows of the table.
/// The value of the iterator is [`PopulationTableRow`].
pub fn iter(&self) -> PopulationTableRefIterator {
pub fn iter(&self) -> impl Iterator<Item = PopulationTableRow> + '_ {
crate::table_iterator::make_table_iterator::<&PopulationTable<'a>>(self)
}

Expand Down
2 changes: 1 addition & 1 deletion src/provenance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ impl<'a> ProvenanceTable<'a> {

/// Return an iterator over rows of the table.
/// The value of the iterator is [`ProvenanceTableRow`].
pub fn iter(&self) -> ProvenanceTableRefIterator {
pub fn iter(&self) -> impl Iterator<Item = ProvenanceTableRow> + '_ {
crate::table_iterator::make_table_iterator::<&ProvenanceTable<'a>>(self)
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/site_table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ fn make_site_table_row(table: &SiteTable, pos: tsk_id_t) -> Option<SiteTableRow>
}
}

pub type SiteTableRefIterator<'a> = crate::table_iterator::TableIterator<&'a SiteTable<'a>>;
pub type SiteTableIterator<'a> = crate::table_iterator::TableIterator<SiteTable<'a>>;
pub(crate) type SiteTableRefIterator<'a> = crate::table_iterator::TableIterator<&'a SiteTable<'a>>;
pub(crate) type SiteTableIterator<'a> = crate::table_iterator::TableIterator<SiteTable<'a>>;

impl<'a> Iterator for SiteTableRefIterator<'a> {
type Item = SiteTableRow;
Expand Down Expand Up @@ -120,7 +120,7 @@ impl<'a> SiteTable<'a> {

/// Return an iterator over rows of the table.
/// The value of the iterator is [`SiteTableRow`].
pub fn iter(&self) -> SiteTableRefIterator {
pub fn iter(&self) -> impl Iterator<Item = SiteTableRow> + '_ {
crate::table_iterator::make_table_iterator::<&SiteTable<'a>>(self)
}

Expand Down
50 changes: 22 additions & 28 deletions src/traits.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
//! Traits related to user-facing types

use crate::edge_table::EdgeTableIterator;
use crate::individual_table::IndividualTableIterator;
use crate::migration_table::MigrationTableIterator;
use crate::mutation_table::MutationTableIterator;
use crate::node_table::NodeTableIterator;
use crate::population_table::PopulationTableIterator;
use crate::site_table::SiteTableIterator;
use crate::table_iterator::make_table_iterator;
use crate::EdgeTable;
use crate::IndividualTable;
Expand Down Expand Up @@ -60,63 +53,64 @@ pub trait TableAccess {
fn edges(&self) -> EdgeTable;

/// Return an iterator over the edges.
/// See [`EdgeTable::iter`] for details.
fn edges_iter(&self) -> EdgeTableIterator {
make_table_iterator::<EdgeTable>(self.edges())
fn edges_iter(&self) -> Box<dyn Iterator<Item = crate::edge_table::EdgeTableRow> + '_> {
Box::new(make_table_iterator::<EdgeTable>(self.edges()))
}

/// Get reference to the [``NodeTable``](crate::NodeTable).
fn nodes(&self) -> NodeTable;

/// Return an iterator over the nodes.
/// See [`NodeTable::iter`] for details.
fn nodes_iter(&self) -> NodeTableIterator {
make_table_iterator::<NodeTable>(self.nodes())
fn nodes_iter(&self) -> Box<dyn Iterator<Item = crate::node_table::NodeTableRow> + '_> {
Box::new(make_table_iterator::<NodeTable>(self.nodes()))
}

/// Get reference to the [``MutationTable``](crate::MutationTable).
fn mutations(&self) -> MutationTable;

/// Return an iterator over the mutations.
/// See [`MutationTable::iter`] for details.
fn mutations_iter(&self) -> MutationTableIterator {
make_table_iterator::<MutationTable>(self.mutations())
fn mutations_iter(
&self,
) -> Box<dyn Iterator<Item = crate::mutation_table::MutationTableRow> + '_> {
Box::new(make_table_iterator::<MutationTable>(self.mutations()))
}

/// Get reference to the [``SiteTable``](crate::SiteTable).
fn sites(&self) -> SiteTable;

/// Return an iterator over the sites.
/// See [`SiteTable::iter`] for details.
fn sites_iter(&self) -> SiteTableIterator {
make_table_iterator::<SiteTable>(self.sites())
fn sites_iter(&self) -> Box<dyn Iterator<Item = crate::site_table::SiteTableRow> + '_> {
Box::new(make_table_iterator::<SiteTable>(self.sites()))
}

/// Get reference to the [``PopulationTable``](crate::PopulationTable).
fn populations(&self) -> PopulationTable;

/// Return an iterator over the populations.
/// See [`PopulationTable::iter`] for details.
fn populations_iter(&self) -> PopulationTableIterator {
make_table_iterator::<PopulationTable>(self.populations())
fn populations_iter(
&self,
) -> Box<dyn Iterator<Item = crate::population_table::PopulationTableRow> + '_> {
Box::new(make_table_iterator::<PopulationTable>(self.populations()))
}

/// Get reference to the [``MigrationTable``](crate::MigrationTable).
fn migrations(&self) -> MigrationTable;

/// Return an iterator over the migration events.
/// See [`MigrationTable::iter`] for details.
fn migrations_iter(&self) -> MigrationTableIterator {
make_table_iterator::<MigrationTable>(self.migrations())
fn migrations_iter(
&self,
) -> Box<dyn Iterator<Item = crate::migration_table::MigrationTableRow> + '_> {
Box::new(make_table_iterator::<MigrationTable>(self.migrations()))
}

/// Get reference to the [``IndividualTable``](crate::IndividualTable).
fn individuals(&self) -> IndividualTable;

/// Return an iterator over the individuals.
/// See [`IndividualTable::iter`] for details.
fn individuals_iter(&self) -> IndividualTableIterator {
make_table_iterator::<IndividualTable>(self.individuals())
fn individuals_iter(
&self,
) -> Box<dyn Iterator<Item = crate::individual_table::IndividualTableRow> + '_> {
Box::new(make_table_iterator::<IndividualTable>(self.individuals()))
}
}

Expand Down