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
2 changes: 1 addition & 1 deletion rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -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"
7 changes: 5 additions & 2 deletions src/edge_table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down Expand Up @@ -320,7 +320,10 @@ impl EdgeTable {
///
/// * `Some(row_view)` if `r` is valid
/// * `None` otherwise
pub fn row_view<E: Into<EdgeId> + Copy>(&self, r: E) -> Option<EdgeTableRowView> {
pub fn row_view<'table, E: Into<EdgeId> + Copy>(
&'table self,
r: E,
) -> Option<EdgeTableRowView<'table>> {
let view = EdgeTableRowView {
table: self,
id: r.into(),
Expand Down
7 changes: 5 additions & 2 deletions src/individual_table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ match tables.individuals().metadata::<MutationMetadata>(0)
crate::table_iterator::make_table_iterator::<&IndividualTable>(self)
}

pub fn lending_iter(&self) -> IndividualTableRowView {
pub fn lending_iter(&'_ self) -> IndividualTableRowView<'_> {
IndividualTableRowView::new(self)
}

Expand Down Expand Up @@ -451,7 +451,10 @@ match tables.individuals().metadata::<MutationMetadata>(0)
///
/// * `Some(row view)` if `r` is valid
/// * `None` otherwise
pub fn row_view<I: Into<IndividualId> + Copy>(&self, r: I) -> Option<IndividualTableRowView> {
pub fn row_view<I: Into<IndividualId> + Copy>(
&'_ self,
r: I,
) -> Option<IndividualTableRowView<'_>> {
let view = IndividualTableRowView {
table: self,
id: r.into(),
Expand Down
7 changes: 5 additions & 2 deletions src/migration_table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down Expand Up @@ -354,7 +354,10 @@ impl MigrationTable {
///
/// * `Some(row view)` if `r` is valid
/// * `None` otherwise
pub fn row_view<M: Into<MigrationId> + Copy>(&self, r: M) -> Option<MigrationTableRowView> {
pub fn row_view<M: Into<MigrationId> + Copy>(
&'_ self,
r: M,
) -> Option<MigrationTableRowView<'_>> {
let view = MigrationTableRowView {
table: self,
id: r.into(),
Expand Down
7 changes: 5 additions & 2 deletions src/mutation_table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down Expand Up @@ -344,7 +344,10 @@ impl MutationTable {
///
/// * `Some(row view)` if `r` is valid
/// * `None` otherwise
pub fn row_view<M: Into<MutationId> + Copy>(&self, r: M) -> Option<MutationTableRowView> {
pub fn row_view<M: Into<MutationId> + Copy>(
&'_ self,
r: M,
) -> Option<MutationTableRowView<'_>> {
let view = MutationTableRowView {
table: self,
id: r.into(),
Expand Down
4 changes: 2 additions & 2 deletions src/node_table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down Expand Up @@ -636,7 +636,7 @@ impl NodeTable {
///
/// * `Some(row view)` if `r` is valid
/// * `None` otherwise
pub fn row_view<N: Into<NodeId> + Copy>(&self, r: N) -> Option<NodeTableRowView> {
pub fn row_view<N: Into<NodeId> + Copy>(&'_ self, r: N) -> Option<NodeTableRowView<'_>> {
let view = NodeTableRowView {
table: self,
id: r.into(),
Expand Down
7 changes: 5 additions & 2 deletions src/population_table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down Expand Up @@ -240,7 +240,10 @@ impl PopulationTable {
///
/// * `Some(row view)` if `r` is valid
/// * `None` otherwise
pub fn row_view<P: Into<PopulationId> + Copy>(&self, r: P) -> Option<PopulationTableRowView> {
pub fn row_view<P: Into<PopulationId> + Copy>(
&'_ self,
r: P,
) -> Option<PopulationTableRowView<'_>> {
match SizeType::try_from(r.into()).ok() {
Some(row) if row < self.num_rows() => {
let view = PopulationTableRowView {
Expand Down
7 changes: 5 additions & 2 deletions src/provenance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,10 @@ impl ProvenanceTable {
///
/// * `Some(row view)` if `r` is valid
/// * `None` otherwise
pub fn row_view<P: Into<ProvenanceId> + Copy>(&self, row: P) -> Option<ProvenanceTableRowView> {
pub fn row_view<P: Into<ProvenanceId> + Copy>(
&'_ self,
row: P,
) -> Option<ProvenanceTableRowView<'_>> {
match row.into().to_usize() {
Some(x) if (x as u64) < self.num_rows() => {
let view = ProvenanceTableRowView {
Expand All @@ -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)
}

Expand Down
4 changes: 2 additions & 2 deletions src/site_table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down Expand Up @@ -279,7 +279,7 @@ impl SiteTable {
///
/// * `Some(row view)` if `r` is valid
/// * `None` otherwise
pub fn row_view<S: Into<SiteId> + Copy>(&self, r: S) -> Option<SiteTableRowView> {
pub fn row_view<S: Into<SiteId> + Copy>(&'_ self, r: S) -> Option<SiteTableRowView<'_>> {
let view = SiteTableRowView {
table: self,
id: r.into(),
Expand Down
2 changes: 1 addition & 1 deletion src/sys/bindings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"));
48 changes: 0 additions & 48 deletions src/test_fixtures.rs
Original file line number Diff line number Diff line change
@@ -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<Vec<u8>, crate::metadata::MetadataError> {
handle_metadata_return!(bincode::serialize(&self))
}

fn decode(md: &[u8]) -> Result<Self, crate::metadata::MetadataError> {
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)]
Expand Down
8 changes: 4 additions & 4 deletions src/trees/tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
21 changes: 13 additions & 8 deletions src/trees/treeseq.rs
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,10 @@ impl TreeSequence {
/// while let Some(tree) = tree_sequence.tree_iterator(tskit::TreeFlags::default()).unwrap().next() {
/// }
/// ```
pub fn tree_iterator<F: Into<TreeFlags>>(&self, flags: F) -> Result<Tree, TskitError> {
pub fn tree_iterator<'ts, F: Into<TreeFlags>>(
&'ts self,
flags: F,
) -> Result<Tree<'ts>, TskitError> {
let tree = Tree::new(&self.inner, flags)?;

Ok(tree)
Expand All @@ -262,11 +265,11 @@ impl TreeSequence {
/// # Errors
///
/// * [`TskitError`] if `at` is not valid
pub fn tree_iterator_at_position<F: Into<TreeFlags>, P: Into<Position>>(
&self,
pub fn tree_iterator_at_position<'ts, F: Into<TreeFlags>, P: Into<Position>>(
&'ts self,
flags: F,
at: P,
) -> Result<Tree, TskitError> {
) -> Result<Tree<'ts>, TskitError> {
Tree::new_at_position(&self.inner, flags, at)
}

Expand All @@ -277,11 +280,11 @@ impl TreeSequence {
/// # Errors
///
/// * [`TskitError`] if `at` is not valid
pub fn tree_iterator_at_index<F: Into<TreeFlags>>(
&self,
pub fn tree_iterator_at_index<'ts, F: Into<TreeFlags>>(
&'ts self,
flags: F,
at: i32,
) -> Result<Tree, TskitError> {
) -> Result<Tree<'ts>, TskitError> {
Tree::new_at_index(&self.inner, flags, at)
}

Expand Down Expand Up @@ -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)
}

Expand Down
Loading