From eee62e0892b1247ce321cd30747ab90d58f49732 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustav=20S=C3=B6rn=C3=A4s?= Date: Wed, 13 Jan 2021 23:19:22 +0100 Subject: document mumlib --- mumlib/src/state.rs | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'mumlib/src/state.rs') diff --git a/mumlib/src/state.rs b/mumlib/src/state.rs index 772e822..182a8fc 100644 --- a/mumlib/src/state.rs +++ b/mumlib/src/state.rs @@ -36,6 +36,9 @@ impl Channel { links: Vec::new(), } } + + /// Create an iterator over this channel and its children in a pre-order + /// traversal. pub fn iter(&self) -> Iter<'_> { Iter { me: Some(&self), @@ -48,6 +51,8 @@ impl Channel { } } + /// Create an iterator over this channel and its childrens connected users + /// in a pre-order traversal. pub fn users_iter(&self) -> UsersIter<'_> { UsersIter { channels: self.children.iter().map(|e| e.users_iter()).collect(), @@ -62,6 +67,7 @@ impl Channel { } } +/// An iterator over channels. Created by [Channel::iter]. pub struct Iter<'a> { me: Option<&'a Channel>, channel: Option, @@ -92,6 +98,7 @@ impl<'a> Iterator for Iter<'a> { } } +/// An iterator over users. Created by [Channel::users_iter]. pub struct UsersIter<'a> { channel: Option, channels: Vec>, -- cgit v1.2.1