diff --git a/rust-toolchain.toml b/rust-toolchain.toml index 83519355..cd45dae9 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,5 +1,5 @@ [toolchain] -channel = "1.87.0" +channel = "1.92.0" components = [ "rustfmt", "clippy" ] targets = ["x86_64-unknown-linux-gnu", "i686-unknown-linux-gnu"] profile = "minimal" diff --git a/src/edge_table.rs b/src/edge_table.rs index b4ccc574..31920d1c 100644 --- a/src/edge_table.rs +++ b/src/edge_table.rs @@ -292,7 +292,7 @@ impl EdgeTable { crate::table_iterator::make_table_iterator::<&EdgeTable>(self) } - pub fn lending_iter(&self) -> EdgeTableRowView { + pub fn lending_iter<'table>(&'table self) -> EdgeTableRowView<'table> { EdgeTableRowView::new(self) } @@ -320,7 +320,10 @@ impl EdgeTable { /// /// * `Some(row_view)` if `r` is valid /// * `None` otherwise - pub fn row_view + Copy>(&self, r: E) -> Option { + pub fn row_view<'table, E: Into + Copy>( + &'table self, + r: E, + ) -> Option> { let view = EdgeTableRowView { table: self, id: r.into(), diff --git a/src/individual_table.rs b/src/individual_table.rs index b77cc602..9148d496 100644 --- a/src/individual_table.rs +++ b/src/individual_table.rs @@ -422,7 +422,7 @@ match tables.individuals().metadata::(0) crate::table_iterator::make_table_iterator::<&IndividualTable>(self) } - pub fn lending_iter(&self) -> IndividualTableRowView { + pub fn lending_iter(&'_ self) -> IndividualTableRowView<'_> { IndividualTableRowView::new(self) } @@ -451,7 +451,10 @@ match tables.individuals().metadata::(0) /// /// * `Some(row view)` if `r` is valid /// * `None` otherwise - pub fn row_view + Copy>(&self, r: I) -> Option { + pub fn row_view + Copy>( + &'_ self, + r: I, + ) -> Option> { let view = IndividualTableRowView { table: self, id: r.into(), diff --git a/src/migration_table.rs b/src/migration_table.rs index 90f09892..044591fd 100644 --- a/src/migration_table.rs +++ b/src/migration_table.rs @@ -325,7 +325,7 @@ impl MigrationTable { crate::table_iterator::make_table_iterator::<&MigrationTable>(self) } - pub fn lending_iter(&self) -> MigrationTableRowView { + pub fn lending_iter(&'_ self) -> MigrationTableRowView<'_> { MigrationTableRowView::new(self) } @@ -354,7 +354,10 @@ impl MigrationTable { /// /// * `Some(row view)` if `r` is valid /// * `None` otherwise - pub fn row_view + Copy>(&self, r: M) -> Option { + pub fn row_view + Copy>( + &'_ self, + r: M, + ) -> Option> { let view = MigrationTableRowView { table: self, id: r.into(), diff --git a/src/mutation_table.rs b/src/mutation_table.rs index df20ed30..a3b9c9b3 100644 --- a/src/mutation_table.rs +++ b/src/mutation_table.rs @@ -315,7 +315,7 @@ impl MutationTable { crate::table_iterator::make_table_iterator::<&MutationTable>(self) } - pub fn lending_iter(&self) -> MutationTableRowView { + pub fn lending_iter(&'_ self) -> MutationTableRowView<'_> { MutationTableRowView::new(self) } @@ -344,7 +344,10 @@ impl MutationTable { /// /// * `Some(row view)` if `r` is valid /// * `None` otherwise - pub fn row_view + Copy>(&self, r: M) -> Option { + pub fn row_view + Copy>( + &'_ self, + r: M, + ) -> Option> { let view = MutationTableRowView { table: self, id: r.into(), diff --git a/src/node_table.rs b/src/node_table.rs index e03cc643..44ea4e29 100644 --- a/src/node_table.rs +++ b/src/node_table.rs @@ -607,7 +607,7 @@ impl NodeTable { crate::table_iterator::make_table_iterator::<&NodeTable>(self) } - pub fn lending_iter(&self) -> NodeTableRowView { + pub fn lending_iter(&'_ self) -> NodeTableRowView<'_> { NodeTableRowView::new(self) } @@ -636,7 +636,7 @@ impl NodeTable { /// /// * `Some(row view)` if `r` is valid /// * `None` otherwise - pub fn row_view + Copy>(&self, r: N) -> Option { + pub fn row_view + Copy>(&'_ self, r: N) -> Option> { let view = NodeTableRowView { table: self, id: r.into(), diff --git a/src/population_table.rs b/src/population_table.rs index 06e6d461..bc5c2a89 100644 --- a/src/population_table.rs +++ b/src/population_table.rs @@ -211,7 +211,7 @@ impl PopulationTable { crate::table_iterator::make_table_iterator::<&PopulationTable>(self) } - pub fn lending_iter(&self) -> PopulationTableRowView { + pub fn lending_iter(&'_ self) -> PopulationTableRowView<'_> { PopulationTableRowView::new(self) } @@ -240,7 +240,10 @@ impl PopulationTable { /// /// * `Some(row view)` if `r` is valid /// * `None` otherwise - pub fn row_view + Copy>(&self, r: P) -> Option { + pub fn row_view + Copy>( + &'_ self, + r: P, + ) -> Option> { match SizeType::try_from(r.into()).ok() { Some(row) if row < self.num_rows() => { let view = PopulationTableRowView { diff --git a/src/provenance.rs b/src/provenance.rs index 94db29db..4299aa49 100644 --- a/src/provenance.rs +++ b/src/provenance.rs @@ -242,7 +242,10 @@ impl ProvenanceTable { /// /// * `Some(row view)` if `r` is valid /// * `None` otherwise - pub fn row_view + Copy>(&self, row: P) -> Option { + pub fn row_view + Copy>( + &'_ self, + row: P, + ) -> Option> { match row.into().to_usize() { Some(x) if (x as u64) < self.num_rows() => { let view = ProvenanceTableRowView { @@ -263,7 +266,7 @@ impl ProvenanceTable { crate::table_iterator::make_table_iterator::<&ProvenanceTable>(self) } - pub fn lending_iter(&self) -> ProvenanceTableRowView { + pub fn lending_iter(&'_ self) -> ProvenanceTableRowView<'_> { ProvenanceTableRowView::new(self) } diff --git a/src/site_table.rs b/src/site_table.rs index 5fe5e21e..30dfb2ee 100644 --- a/src/site_table.rs +++ b/src/site_table.rs @@ -250,7 +250,7 @@ impl SiteTable { crate::table_iterator::make_table_iterator::<&SiteTable>(self) } - pub fn lending_iter(&self) -> SiteTableRowView { + pub fn lending_iter(&'_ self) -> SiteTableRowView<'_> { SiteTableRowView::new(self) } @@ -279,7 +279,7 @@ impl SiteTable { /// /// * `Some(row view)` if `r` is valid /// * `None` otherwise - pub fn row_view + Copy>(&self, r: S) -> Option { + pub fn row_view + Copy>(&'_ self, r: S) -> Option> { let view = SiteTableRowView { table: self, id: r.into(), diff --git a/src/sys/bindings.rs b/src/sys/bindings.rs index bbe69c40..b6132258 100644 --- a/src/sys/bindings.rs +++ b/src/sys/bindings.rs @@ -28,5 +28,5 @@ //! This module contains the same types/functions with the same names. #![allow(clippy::all)] - +#![allow(unnecessary_transmutes)] include!(concat!(env!("OUT_DIR"), "/auto_bindings.rs")); diff --git a/src/test_fixtures.rs b/src/test_fixtures.rs index b42ff2b5..c77f9a90 100644 --- a/src/test_fixtures.rs +++ b/src/test_fixtures.rs @@ -1,51 +1,3 @@ -#[cfg(test)] -use crate::*; - -#[cfg(test)] -#[derive(serde::Serialize, serde::Deserialize, Debug, Eq, PartialEq, Copy, Clone)] -pub struct GenericMetadata { - pub data: i64, -} - -#[cfg(test)] -impl Default for GenericMetadata { - fn default() -> Self { - Self { data: 42 } - } -} - -#[cfg(test)] -impl crate::metadata::MetadataRoundtrip for GenericMetadata { - fn encode(&self) -> Result, crate::metadata::MetadataError> { - handle_metadata_return!(bincode::serialize(&self)) - } - - fn decode(md: &[u8]) -> Result { - handle_metadata_return!(bincode::deserialize(md)) - } -} - -#[cfg(test)] -impl crate::metadata::MutationMetadata for GenericMetadata {} - -#[cfg(test)] -impl crate::metadata::SiteMetadata for GenericMetadata {} - -#[cfg(test)] -impl crate::metadata::EdgeMetadata for GenericMetadata {} - -#[cfg(test)] -impl crate::metadata::NodeMetadata for GenericMetadata {} - -#[cfg(test)] -impl crate::metadata::IndividualMetadata for GenericMetadata {} - -#[cfg(test)] -impl crate::metadata::PopulationMetadata for GenericMetadata {} - -#[cfg(test)] -impl crate::metadata::MigrationMetadata for GenericMetadata {} - #[cfg(test)] pub mod bad_metadata { #[derive(serde::Serialize, serde::Deserialize, Debug)] diff --git a/src/trees/tree.rs b/src/trees/tree.rs index 5891acd5..fa6cd135 100644 --- a/src/trees/tree.rs +++ b/src/trees/tree.rs @@ -77,7 +77,7 @@ impl<'treeseq> Tree<'treeseq> { /// # Failing examples /// - /// An error will be returned if ['crate::TreeFlags::SAMPLE_LISTS`] is not used: + /// An error will be returned if ['TreeFlags::SAMPLE_LISTS`](crate::TreeFlags::SAMPLE_LISTS) is not used: /// /// ```should_panic /// use tskit::StreamingIterator; @@ -337,7 +337,7 @@ impl<'treeseq> Tree<'treeseq> { /// # Failing examples /// - /// An error will be returned if ['crate::TreeFlags::SAMPLE_LISTS`] is not used: + /// An error will be returned if ['TreeFlags::SAMPLE_LISTS`](crate::TreeFlags::SAMPLE_LISTS) is not used: /// /// ```should_panic /// use tskit::StreamingIterator; @@ -371,7 +371,7 @@ impl<'treeseq> Tree<'treeseq> { /// # Failing examples /// - /// An error will be returned if ['crate::TreeFlags::SAMPLE_LISTS`] is not used: + /// An error will be returned if ['TreeFlags::SAMPLE_LISTS`](crate::TreeFlags::SAMPLE_LISTS) is not used: /// /// ```should_panic /// use tskit::StreamingIterator; @@ -405,7 +405,7 @@ impl<'treeseq> Tree<'treeseq> { /// # Failing examples /// - /// An error will be returned if ['crate::TreeFlags::SAMPLE_LISTS`] is not used: + /// An error will be returned if ['TreeFlags::SAMPLE_LISTS`](crate::TreeFlags::SAMPLE_LISTS) is not used: /// /// ```should_panic /// use tskit::StreamingIterator; diff --git a/src/trees/treeseq.rs b/src/trees/treeseq.rs index 0f76adbd..6a086367 100644 --- a/src/trees/treeseq.rs +++ b/src/trees/treeseq.rs @@ -249,7 +249,10 @@ impl TreeSequence { /// while let Some(tree) = tree_sequence.tree_iterator(tskit::TreeFlags::default()).unwrap().next() { /// } /// ``` - pub fn tree_iterator>(&self, flags: F) -> Result { + pub fn tree_iterator<'ts, F: Into>( + &'ts self, + flags: F, + ) -> Result, TskitError> { let tree = Tree::new(&self.inner, flags)?; Ok(tree) @@ -262,11 +265,11 @@ impl TreeSequence { /// # Errors /// /// * [`TskitError`] if `at` is not valid - pub fn tree_iterator_at_position, P: Into>( - &self, + pub fn tree_iterator_at_position<'ts, F: Into, P: Into>( + &'ts self, flags: F, at: P, - ) -> Result { + ) -> Result, TskitError> { Tree::new_at_position(&self.inner, flags, at) } @@ -277,11 +280,11 @@ impl TreeSequence { /// # Errors /// /// * [`TskitError`] if `at` is not valid - pub fn tree_iterator_at_index>( - &self, + pub fn tree_iterator_at_index<'ts, F: Into>( + &'ts self, flags: F, at: i32, - ) -> Result { + ) -> Result, TskitError> { Tree::new_at_index(&self.inner, flags, at) } @@ -481,7 +484,9 @@ impl TreeSequence { } /// Build an iterator over edge differences. - pub fn edge_differences_iter(&self) -> crate::edge_differences::EdgeDifferencesIterator { + pub fn edge_differences_iter<'ts>( + &'ts self, + ) -> crate::edge_differences::EdgeDifferencesIterator<'ts> { crate::edge_differences::EdgeDifferencesIterator::new(self) }