Skip to content

Commit 4ba44ef

Browse files
authored
Bump editions to 2021. (#198)
* Bump tskit-derive version to 0.2.0 to match edition change. * Update to new 2021 prelude Closes #193
1 parent c4cc6e8 commit 4ba44ef

14 files changed

+8
-24
lines changed

Cargo.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name = "tskit"
33
version = "0.6.1"
44
authors = ["tskit developers <[email protected]>"]
55
build = "build.rs"
6-
edition = "2018"
6+
edition = "2021"
77
description = "rust interface to tskit"
88
license = "MIT"
99
homepage = "https://github.com/tskit-dev/tskit-rust"
@@ -24,7 +24,7 @@ humantime = {version = "2.1.0", optional = true}
2424
serde = {version = "1.0.118", features = ["derive"], optional = true}
2525
serde_json = {version = "1.0.67", optional = true}
2626
bincode = {version = "1.3.1", optional = true}
27-
tskit-derive = {version = "0.1.0", path = "tskit-derive", optional = true}
27+
tskit-derive = {version = "0.2.0", path = "tskit-derive", optional = true}
2828

2929
[dev-dependencies]
3030
clap = "~2.34.0"

src/_macros.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ macro_rules! unsafe_tsk_column_access {
4646

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

7473
($i: expr, $lo: expr, $hi: expr, $array: expr, $offset_array: expr, $offset_array_len: expr, $output_id_type: expr) => {{
75-
use std::convert::TryFrom;
7674
let i = crate::SizeType::try_from($i)?;
7775
if $i < $lo || i >= $hi {
7876
Err(TskitError::IndexError {})
@@ -103,7 +101,6 @@ macro_rules! unsafe_tsk_ragged_column_access {
103101
#[allow(unused_macros)]
104102
macro_rules! unsafe_tsk_ragged_char_column_access {
105103
($i: expr, $lo: expr, $hi: expr, $array: expr, $offset_array: expr, $offset_array_len: expr) => {{
106-
use std::convert::TryFrom;
107104
let i = crate::SizeType::try_from($i)?;
108105
if $i < $lo || i >= $hi {
109106
Err(TskitError::IndexError {})
@@ -305,7 +302,7 @@ macro_rules! impl_id_traits {
305302
}
306303
}
307304

308-
impl std::convert::TryFrom<$idtype> for crate::SizeType {
305+
impl TryFrom<$idtype> for crate::SizeType {
309306
type Error = crate::TskitError;
310307

311308
fn try_from(value: $idtype) -> Result<Self, Self::Error> {

src/edge_table.rs

-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ impl PartialEq for EdgeTableRow {
2525
}
2626

2727
fn make_edge_table_row(table: &EdgeTable, pos: tsk_id_t) -> Option<EdgeTableRow> {
28-
use std::convert::TryFrom;
2928
// panic is okay here, as we are handling a bad
3029
// input value before we first call this to
3130
// set up the iterator

src/individual_table.rs

-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ pub struct IndividualTable<'a> {
4949
}
5050

5151
fn make_individual_table_row(table: &IndividualTable, pos: tsk_id_t) -> Option<IndividualTableRow> {
52-
use std::convert::TryFrom;
5352
// panic is okay here, as we are handling a bad
5453
// input value before we first call this to
5554
// set up the iterator

src/lib.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ impl From<usize> for SizeType {
286286
}
287287
}
288288

289-
impl std::convert::TryFrom<tsk_id_t> for SizeType {
289+
impl TryFrom<tsk_id_t> for SizeType {
290290
type Error = crate::TskitError;
291291

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

300-
impl std::convert::TryFrom<SizeType> for tsk_id_t {
300+
impl TryFrom<SizeType> for tsk_id_t {
301301
type Error = crate::TskitError;
302302

303303
fn try_from(value: SizeType) -> Result<Self, Self::Error> {

src/metadata.rs

-1
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,6 @@ mod tests {
313313
Ok(rv)
314314
}
315315
fn decode(md: &[u8]) -> Result<Self, MetadataError> {
316-
use std::convert::TryInto;
317316
let (x_int_bytes, rest) = md.split_at(std::mem::size_of::<i32>());
318317
let (y_int_bytes, _) = rest.split_at(std::mem::size_of::<u32>());
319318
Ok(Self {

src/migration_table.rs

-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ impl PartialEq for MigrationTableRow {
3030
}
3131

3232
fn make_migration_table_row(table: &MigrationTable, pos: tsk_id_t) -> Option<MigrationTableRow> {
33-
use std::convert::TryFrom;
3433
// panic is okay here, as we are handling a bad
3534
// input value before we first call this to
3635
// set up the iterator

src/mutation_table.rs

-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ impl PartialEq for MutationTableRow {
2828
}
2929

3030
fn make_mutation_table_row(table: &MutationTable, pos: tsk_id_t) -> Option<MutationTableRow> {
31-
use std::convert::TryFrom;
3231
// panic is okay here, as we are handling a bad
3332
// input value before we first call this to
3433
// set up the iterator

src/node_table.rs

-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ impl PartialEq for NodeTableRow {
2626
}
2727

2828
fn make_node_table_row(table: &NodeTable, pos: tsk_id_t) -> Option<NodeTableRow> {
29-
use std::convert::TryFrom;
3029
// panic is okay here, as we are handling a bad
3130
// input value before we first call this to
3231
// set up the iterator

src/population_table.rs

-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ impl PartialEq for PopulationTableRow {
1919
}
2020

2121
fn make_population_table_row(table: &PopulationTable, pos: tsk_id_t) -> Option<PopulationTableRow> {
22-
use std::convert::TryFrom;
2322
// panic is okay here, as we are handling a bad
2423
// input value before we first call this to
2524
// set up the iterator

src/provenance.rs

-1
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,6 @@ impl std::fmt::Display for ProvenanceTableRow {
131131
}
132132

133133
fn make_provenance_table_row(table: &ProvenanceTable, pos: tsk_id_t) -> Option<ProvenanceTableRow> {
134-
use std::convert::TryFrom;
135134
// panic is okay here, as we are handling a bad
136135
// input value before we first call this to
137136
// set up the iterator

src/site_table.rs

-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ impl PartialEq for SiteTableRow {
2323
}
2424

2525
fn make_site_table_row(table: &SiteTable, pos: tsk_id_t) -> Option<SiteTableRow> {
26-
use std::convert::TryFrom;
2726
// panic is okay here, as we are handling a bad
2827
// input value before we first call this to
2928
// set up the iterator

src/table_collection.rs

+1-5
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ use ll_bindings::tsk_table_collection_free;
7878
/// Ok(rv)
7979
/// }
8080
/// fn decode(md: &[u8]) -> Result<Self, tskit::metadata::MetadataError> {
81-
/// use std::convert::TryInto;
81+
///
8282
/// let (x_int_bytes, rest) = md.split_at(std::mem::size_of::<i32>());
8383
/// Ok(Self {
8484
/// x: i32::from_le_bytes(x_int_bytes.try_into().unwrap()),
@@ -1048,8 +1048,6 @@ mod test {
10481048

10491049
#[test]
10501050
fn test_add_mutation() {
1051-
use std::convert::TryFrom;
1052-
10531051
let mut tables = TableCollection::new(1000.).unwrap();
10541052

10551053
tables
@@ -1141,7 +1139,6 @@ mod test {
11411139
Ok(rv)
11421140
}
11431141
fn decode(md: &[u8]) -> Result<Self, MetadataError> {
1144-
use std::convert::TryInto;
11451142
let (x_int_bytes, rest) = md.split_at(std::mem::size_of::<i32>());
11461143
let (y_int_bytes, _) = rest.split_at(std::mem::size_of::<u32>());
11471144
Ok(Self {
@@ -1757,7 +1754,6 @@ mod test_adding_migrations {
17571754
#[test]
17581755
fn test_add_migration_with_metadata() {
17591756
use crate::metadata::MetadataRoundtrip;
1760-
use std::convert::TryInto;
17611757

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

tskit-derive/Cargo.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "tskit-derive"
3-
version = "0.1.0"
4-
edition = "2018"
3+
version = "0.2.0"
4+
edition = "2021"
55
authors = ["tskit developers <[email protected]>"]
66
description = "procedural macros for tskit-rust"
77
license = "MIT"

0 commit comments

Comments
 (0)