aboutsummaryrefslogtreecommitdiffstats
path: root/mumlib/src/state.rs
diff options
context:
space:
mode:
Diffstat (limited to 'mumlib/src/state.rs')
-rw-r--r--mumlib/src/state.rs7
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>>,