diff options
| author | Gustav Sörnäs <gustav@sornas.net> | 2021-01-13 23:19:22 +0100 |
|---|---|---|
| committer | Gustav Sörnäs <gustav@sornas.net> | 2021-06-13 12:16:39 +0200 |
| commit | eee62e0892b1247ce321cd30747ab90d58f49732 (patch) | |
| tree | 9145e96680d3fac42dc67387c460b307ce4156af /mumlib/src/state.rs | |
| parent | 54153914d22180777b25a1d4f5089ed2ae2839df (diff) | |
| download | mum-eee62e0892b1247ce321cd30747ab90d58f49732.tar.gz | |
document mumlib
Diffstat (limited to 'mumlib/src/state.rs')
| -rw-r--r-- | mumlib/src/state.rs | 7 |
1 files changed, 7 insertions, 0 deletions
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<usize>, @@ -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<usize>, channels: Vec<UsersIter<'a>>, |
