diff options
-rw-r--r-- | lib/domain/libimagmail/src/mailtree.rs | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/lib/domain/libimagmail/src/mailtree.rs b/lib/domain/libimagmail/src/mailtree.rs index 3b7ca745..944a0c4b 100644 --- a/lib/domain/libimagmail/src/mailtree.rs +++ b/lib/domain/libimagmail/src/mailtree.rs @@ -52,6 +52,27 @@ impl Mailtree { pub fn traverse(&self) -> Traverse { Traverse::with(self) } + + #[cfg(test)] + fn fill_from_iter<I>(mut it: I) -> Option<(NodeId, Mailtree)> + where I: Iterator<Item = String> + { + let mut arena = Arena::new(); + if let Some(rootdata) = it.next() { + let root = arena.new_node(rootdata); + let mut old_id = root.clone(); + + while let Some(next_data) = it.next() { + let next_id = arena.new_node(next_data); + old_id.append(next_id.clone(), &mut arena); + + old_id = next_id; + } + Some((root, Mailtree { arena, root: root })) + } else { + None + } + } } fn fill_arena_with<'a>(arena: &mut Arena<String>, store: &'a MailStoreWithConnection<'a>, root: LoadedMail) -> Result<NodeId> { |