From 1bd6a7e178c749870cfbbf03fdf097457cc849cf Mon Sep 17 00:00:00 2001 From: "Kevin R. Thornton" Date: Tue, 1 Nov 2022 11:53:47 -0700 Subject: [PATCH] test: add doc tests for node table --- src/node_table.rs | 148 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 148 insertions(+) diff --git a/src/node_table.rs b/src/node_table.rs index b48c395e4..d07a7678e 100644 --- a/src/node_table.rs +++ b/src/node_table.rs @@ -88,6 +88,21 @@ impl<'a> NodeTable<'a> { /// /// * `Some(time)` if `row` is valid. /// * `None` otherwise. + /// + /// # Examples + /// + /// ``` + /// # use tskit::prelude::*; + /// # let mut tables = tskit::TableCollection::new(10.).unwrap(); + /// # tables.add_node(0, 10.0, -1, -1).unwrap(); + /// if let Some(time) = tables.nodes().time(0) { + /// // then node id 0 is a valid row id + /// # assert_eq!(time, 10.0); + /// } + /// # else { + /// # panic!("expected 0 to be a valid row id") + /// # } + /// ``` pub fn time + Copy>(&'a self, row: N) -> Option