diff --git a/src/_macros.rs b/src/_macros.rs index 779b63503..8c7a321f3 100644 --- a/src/_macros.rs +++ b/src/_macros.rs @@ -173,6 +173,12 @@ macro_rules! impl_id_traits { self.partial_cmp(&other.0) } } + + impl Default for $idtype { + fn default() -> Self { + Self::NULL + } + } }; } diff --git a/src/newtypes.rs b/src/newtypes.rs index 081cc8452..05b2be6a9 100644 --- a/src/newtypes.rs +++ b/src/newtypes.rs @@ -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);