//! Iterators of `RcNode`, returned by `iter_rc()`. use crate::rust::*; use super::{CountedRawIter, Node, RcNode}; /// An iterator over the child `Node`s of `RcNode` with shared ownership. /// /// This `struct` is created by [`RcNode::iter_rc`]. /// See its document for more. /// /// [`RcNode::iter_rc`]: ../rc/enum.RcNode.html#method.iter_rc pub struct IterRc { iter : CountedRawIter, mark : PhantomData>, } impl Iterator for IterRc { type Item = RcNode; fn next( &mut self ) -> Option> { self.iter.next().map( |node| unsafe{ node.as_ref().rc() }) } fn size_hint( &self ) -> ( usize, Option ) { self.iter.size_hint() } } impl IterRc { pub(crate) fn new( curr: Option>>, len: usize ) -> Self { IterRc { iter: CountedRawIter::new( curr, len ), mark: PhantomData, } } } impl Clone for IterRc { fn clone( &self ) -> Self { IterRc { ..*self } } }