From e9327bb8aa3e176973c7b9b7a8646088774dc9c5 Mon Sep 17 00:00:00 2001 From: "Kevin R. Thornton" Date: Thu, 16 Mar 2023 05:28:33 -0700 Subject: [PATCH] feat: impl Default for row id types --- src/_macros.rs | 6 ++++++ src/newtypes.rs | 3 +++ 2 files changed, 9 insertions(+) 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);