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
feat: impl Default for row id types
  • Loading branch information
molpopgen committed Mar 16, 2023
commit e9327bb8aa3e176973c7b9b7a8646088774dc9c5
6 changes: 6 additions & 0 deletions src/_macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,12 @@ macro_rules! impl_id_traits {
self.partial_cmp(&other.0)
}
}

impl Default for $idtype {
fn default() -> Self {
Self::NULL
}
}
};
}

Expand Down
3 changes: 3 additions & 0 deletions src/newtypes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ use bindings::tsk_size_t;
/// use tskit::NodeId;
/// use tskit::bindings::tsk_id_t;
///
/// // The default value is null:
/// assert_eq!(tskit::NodeId::default(), tskit::NodeId::NULL);
///
/// let x: tsk_id_t = 1;
/// let y: NodeId = NodeId::from(x);
/// assert_eq!(x, y);
Expand Down