Skip to content

Update to rust 2021 edition #198

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 13, 2021
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
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name = "tskit"
version = "0.6.1"
authors = ["tskit developers <admin@tskit.dev>"]
build = "build.rs"
edition = "2018"
edition = "2021"
description = "rust interface to tskit"
license = "MIT"
homepage = "https://github.com/tskit-dev/tskit-rust"
Expand All @@ -24,7 +24,7 @@ humantime = {version = "2.1.0", optional = true}
serde = {version = "1.0.118", features = ["derive"], optional = true}
serde_json = {version = "1.0.67", optional = true}
bincode = {version = "1.3.1", optional = true}
tskit-derive = {version = "0.1.0", path = "tskit-derive", optional = true}
tskit-derive = {version = "0.2.0", path = "tskit-derive", optional = true}

[dev-dependencies]
clap = "~2.34.0"
Expand Down
5 changes: 1 addition & 4 deletions src/_macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ macro_rules! unsafe_tsk_column_access {

macro_rules! unsafe_tsk_ragged_column_access {
($i: expr, $lo: expr, $hi: expr, $array: expr, $offset_array: expr, $offset_array_len: expr) => {{
use std::convert::TryFrom;
let i = crate::SizeType::try_from($i)?;
if $i < $lo || i >= $hi {
Err(TskitError::IndexError {})
Expand All @@ -72,7 +71,6 @@ macro_rules! unsafe_tsk_ragged_column_access {
}};

($i: expr, $lo: expr, $hi: expr, $array: expr, $offset_array: expr, $offset_array_len: expr, $output_id_type: expr) => {{
use std::convert::TryFrom;
let i = crate::SizeType::try_from($i)?;
if $i < $lo || i >= $hi {
Err(TskitError::IndexError {})
Expand Down Expand Up @@ -103,7 +101,6 @@ macro_rules! unsafe_tsk_ragged_column_access {
#[allow(unused_macros)]
macro_rules! unsafe_tsk_ragged_char_column_access {
($i: expr, $lo: expr, $hi: expr, $array: expr, $offset_array: expr, $offset_array_len: expr) => {{
use std::convert::TryFrom;
let i = crate::SizeType::try_from($i)?;
if $i < $lo || i >= $hi {
Err(TskitError::IndexError {})
Expand Down Expand Up @@ -305,7 +302,7 @@ macro_rules! impl_id_traits {
}
}

impl std::convert::TryFrom<$idtype> for crate::SizeType {
impl TryFrom<$idtype> for crate::SizeType {
type Error = crate::TskitError;

fn try_from(value: $idtype) -> Result<Self, Self::Error> {
Expand Down
1 change: 0 additions & 1 deletion src/edge_table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ impl PartialEq for EdgeTableRow {
}

fn make_edge_table_row(table: &EdgeTable, pos: tsk_id_t) -> Option<EdgeTableRow> {
use std::convert::TryFrom;
// panic is okay here, as we are handling a bad
// input value before we first call this to
// set up the iterator
Expand Down
1 change: 0 additions & 1 deletion src/individual_table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ pub struct IndividualTable<'a> {
}

fn make_individual_table_row(table: &IndividualTable, pos: tsk_id_t) -> Option<IndividualTableRow> {
use std::convert::TryFrom;
// panic is okay here, as we are handling a bad
// input value before we first call this to
// set up the iterator
Expand Down
4 changes: 2 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ impl From<usize> for SizeType {
}
}

impl std::convert::TryFrom<tsk_id_t> for SizeType {
impl TryFrom<tsk_id_t> for SizeType {
type Error = crate::TskitError;

fn try_from(value: tsk_id_t) -> Result<Self, Self::Error> {
Expand All @@ -297,7 +297,7 @@ impl std::convert::TryFrom<tsk_id_t> for SizeType {
}
}

impl std::convert::TryFrom<SizeType> for tsk_id_t {
impl TryFrom<SizeType> for tsk_id_t {
type Error = crate::TskitError;

fn try_from(value: SizeType) -> Result<Self, Self::Error> {
Expand Down
1 change: 0 additions & 1 deletion src/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,6 @@ mod tests {
Ok(rv)
}
fn decode(md: &[u8]) -> Result<Self, MetadataError> {
use std::convert::TryInto;
let (x_int_bytes, rest) = md.split_at(std::mem::size_of::<i32>());
let (y_int_bytes, _) = rest.split_at(std::mem::size_of::<u32>());
Ok(Self {
Expand Down
1 change: 0 additions & 1 deletion src/migration_table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ impl PartialEq for MigrationTableRow {
}

fn make_migration_table_row(table: &MigrationTable, pos: tsk_id_t) -> Option<MigrationTableRow> {
use std::convert::TryFrom;
// panic is okay here, as we are handling a bad
// input value before we first call this to
// set up the iterator
Expand Down
1 change: 0 additions & 1 deletion src/mutation_table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ impl PartialEq for MutationTableRow {
}

fn make_mutation_table_row(table: &MutationTable, pos: tsk_id_t) -> Option<MutationTableRow> {
use std::convert::TryFrom;
// panic is okay here, as we are handling a bad
// input value before we first call this to
// set up the iterator
Expand Down
1 change: 0 additions & 1 deletion src/node_table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ impl PartialEq for NodeTableRow {
}

fn make_node_table_row(table: &NodeTable, pos: tsk_id_t) -> Option<NodeTableRow> {
use std::convert::TryFrom;
// panic is okay here, as we are handling a bad
// input value before we first call this to
// set up the iterator
Expand Down
1 change: 0 additions & 1 deletion src/population_table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ impl PartialEq for PopulationTableRow {
}

fn make_population_table_row(table: &PopulationTable, pos: tsk_id_t) -> Option<PopulationTableRow> {
use std::convert::TryFrom;
// panic is okay here, as we are handling a bad
// input value before we first call this to
// set up the iterator
Expand Down
1 change: 0 additions & 1 deletion src/provenance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,6 @@ impl std::fmt::Display for ProvenanceTableRow {
}

fn make_provenance_table_row(table: &ProvenanceTable, pos: tsk_id_t) -> Option<ProvenanceTableRow> {
use std::convert::TryFrom;
// panic is okay here, as we are handling a bad
// input value before we first call this to
// set up the iterator
Expand Down
1 change: 0 additions & 1 deletion src/site_table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ impl PartialEq for SiteTableRow {
}

fn make_site_table_row(table: &SiteTable, pos: tsk_id_t) -> Option<SiteTableRow> {
use std::convert::TryFrom;
// panic is okay here, as we are handling a bad
// input value before we first call this to
// set up the iterator
Expand Down
6 changes: 1 addition & 5 deletions src/table_collection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ use ll_bindings::tsk_table_collection_free;
/// Ok(rv)
/// }
/// fn decode(md: &[u8]) -> Result<Self, tskit::metadata::MetadataError> {
/// use std::convert::TryInto;
///
/// let (x_int_bytes, rest) = md.split_at(std::mem::size_of::<i32>());
/// Ok(Self {
/// x: i32::from_le_bytes(x_int_bytes.try_into().unwrap()),
Expand Down Expand Up @@ -1048,8 +1048,6 @@ mod test {

#[test]
fn test_add_mutation() {
use std::convert::TryFrom;

let mut tables = TableCollection::new(1000.).unwrap();

tables
Expand Down Expand Up @@ -1141,7 +1139,6 @@ mod test {
Ok(rv)
}
fn decode(md: &[u8]) -> Result<Self, MetadataError> {
use std::convert::TryInto;
let (x_int_bytes, rest) = md.split_at(std::mem::size_of::<i32>());
let (y_int_bytes, _) = rest.split_at(std::mem::size_of::<u32>());
Ok(Self {
Expand Down Expand Up @@ -1757,7 +1754,6 @@ mod test_adding_migrations {
#[test]
fn test_add_migration_with_metadata() {
use crate::metadata::MetadataRoundtrip;
use std::convert::TryInto;

let metadata = vec![GenericMetadata::default(), GenericMetadata { data: 84 }];

Expand Down
4 changes: 2 additions & 2 deletions tskit-derive/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "tskit-derive"
version = "0.1.0"
edition = "2018"
version = "0.2.0"
edition = "2021"
authors = ["tskit developers <admin@tskit.dev>"]
description = "procedural macros for tskit-rust"
license = "MIT"
Expand Down