Skip to content

Commit 541f516

Browse files
authored
feat: impl Default for row id types (#484)
1 parent 77ae8a9 commit 541f516

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

src/_macros.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,12 @@ macro_rules! impl_id_traits {
173173
self.partial_cmp(&other.0)
174174
}
175175
}
176+
177+
impl Default for $idtype {
178+
fn default() -> Self {
179+
Self::NULL
180+
}
181+
}
176182
};
177183
}
178184

src/newtypes.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ use bindings::tsk_size_t;
1717
/// use tskit::NodeId;
1818
/// use tskit::bindings::tsk_id_t;
1919
///
20+
/// // The default value is null:
21+
/// assert_eq!(tskit::NodeId::default(), tskit::NodeId::NULL);
22+
///
2023
/// let x: tsk_id_t = 1;
2124
/// let y: NodeId = NodeId::from(x);
2225
/// assert_eq!(x, y);

0 commit comments

Comments
 (0)