Skip to content

Commit

Permalink
replace IdIsNull trait with associated fn (#156)
Browse files Browse the repository at this point in the history
  • Loading branch information
molpopgen authored Aug 20, 2021
1 parent 9987fc0 commit 258b4ee
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 12 deletions.
11 changes: 5 additions & 6 deletions src/_macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,11 @@ macro_rules! impl_id_traits {
impl $idtype {
/// NULL value for this type.
pub const NULL: $idtype = Self($crate::TSK_NULL);

/// Return `true` is `self == Self::NULL`
pub fn is_null(&self) -> bool {
*self == Self::NULL
}
}

impl From<$crate::tsk_id_t> for $idtype {
Expand All @@ -267,12 +272,6 @@ macro_rules! impl_id_traits {
}
}

impl $crate::IdIsNull for $idtype {
fn is_null(&self) -> bool {
self.0 == Self::NULL
}
}

impl From<$idtype> for usize {
fn from(value: $idtype) -> Self {
value.0 as usize
Expand Down
1 change: 0 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,6 @@ pub use node_table::{NodeTable, NodeTableRow};
pub use population_table::{PopulationTable, PopulationTableRow};
pub use site_table::{SiteTable, SiteTableRow};
pub use table_collection::TableCollection;
pub use traits::IdIsNull;
pub use traits::NodeListGenerator;
pub use traits::TableAccess;
pub use traits::TskitTypeAccess;
Expand Down
1 change: 0 additions & 1 deletion src/test_simplification.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
mod tests {
use crate::test_fixtures::make_small_table_collection_two_trees;
use crate::test_fixtures::treeseq_from_small_table_collection_two_trees;
use crate::IdIsNull;
use crate::NodeId;
use crate::SimplificationOptions;
use crate::TableAccess;
Expand Down
4 changes: 0 additions & 4 deletions src/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,3 @@ pub trait NodeListGenerator: TableAccess {
self.nodes().create_node_id_vector(f)
}
}

pub trait IdIsNull {
fn is_null(&self) -> bool;
}

0 comments on commit 258b4ee

Please sign in to comment.