Skip to content

replace IdIsNull trait with associated fn #156

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
Aug 20, 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
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;
}