@@ -392,9 +392,10 @@ impl TreeInterface {
392
392
393
393
/// Return an [`Iterator`] from the node `u` to the root of the tree.
394
394
///
395
- /// # Errors
395
+ /// # Returns
396
396
///
397
- /// [`TskitError::IndexError`] if `u` is out of range.
397
+ /// * `Some(iterator)` if `u` us valid
398
+ /// * `None` otherwise
398
399
#[ deprecated( since = "0.2.3" , note = "Please use Tree::parents instead" ) ]
399
400
pub fn path_to_root ( & self , u : NodeId ) -> Option < impl Iterator < Item = NodeId > + ' _ > {
400
401
self . parents ( u)
@@ -403,32 +404,34 @@ impl TreeInterface {
403
404
/// Return an [`Iterator`] from the node `u` to the root of the tree,
404
405
/// travering all parent nodes.
405
406
///
406
- /// # Errors
407
+ /// # Returns
407
408
///
408
- /// [`TskitError::IndexError`] if `u` is out of range.
409
+ /// * `Some(iterator)` if `u` is valid
410
+ /// * `None` otherwise
409
411
pub fn parents ( & self , u : NodeId ) -> Option < impl Iterator < Item = NodeId > + ' _ > {
410
412
ParentsIterator :: new ( self , u)
411
413
}
412
414
413
415
/// Return an [`Iterator`] over the children of node `u`.
416
+ /// # Returns
414
417
///
415
- /// # Errors
416
- ///
417
- /// [`TskitError::IndexError`] if `u` is out of range.
418
+ /// * `Some(iterator)` if `u` is valid
419
+ /// * `None` otherwise
418
420
pub fn children ( & self , u : NodeId ) -> Option < impl Iterator < Item = NodeId > + ' _ > {
419
421
ChildIterator :: new ( self , u)
420
422
}
423
+
421
424
/// Return an [`Iterator`] over the sample nodes descending from node `u`.
422
425
///
423
426
/// # Note
424
427
///
425
428
/// If `u` is itself a sample, then it is included in the values returned.
426
- /// Returns `None` if `u` is out of range.
427
- ///
428
- /// # Errors
429
+ ///
430
+ /// # Returns
429
431
///
430
- /// [`TskitError::NotTrackingSamples`] if [`TreeFlags::SAMPLE_LISTS`] was not used
431
- /// to initialize `self`.
432
+ /// * Some(Ok(iterator)) if [`TreeFlags::SAMPLE_LISTS`] is in [`TreeInterface::flags`]
433
+ /// * Some(Err(_)) if [`TreeFlags::SAMPLE_LISTS`] is not in [`TreeInterface::flags`]
434
+ /// * None if `u` is not valid.
432
435
pub fn samples (
433
436
& self ,
434
437
u : NodeId ,
0 commit comments