diff options
| -rw-r--r-- | README.md | 2 | ||||
| -rw-r--r-- | src/messages.rs | 32 |
2 files changed, 33 insertions, 1 deletions
@@ -5,7 +5,7 @@ This is not much more than a wrapper for the [notmuch](https://notmuchmail.org/) [](https://travis-ci.org/vhdirk/notmuch-rs) [](https://crates.io/crates/notmuch) [](https://crates.io/crates/notmuch) -[](https://crates.io/crates/notmuch) +[](https://crates.io/crates/notmuch) [](https://gitter.im/notmuch-rs/Lobby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) ## Building diff --git a/src/messages.rs b/src/messages.rs index 01e0ea4..dc0f59e 100644 --- a/src/messages.rs +++ b/src/messages.rs @@ -104,3 +104,35 @@ impl<'o, O> MessagesExt<'o, O> for Messages<'o, O> where O: MessageOwner + 'o {} unsafe impl<'o, O> Send for Messages<'o, O> where O: MessageOwner + 'o {} unsafe impl<'o, O> Sync for Messages<'o, O> where O: MessageOwner + 'o {} + +#[cfg(test)] +mod tests { + // This will not compile if ownership can't be subject to recursion + fn descend<'o, O: 'o + super::MessageOwner, T: Iterator<Item=super::Message<'o, O>>>(iter: T) + -> usize { + iter.map(|msg| descend(msg.replies()) ).count() + } + + use query::Query; + use database; + + #[test] + #[should_panic] // until test data is filled in + fn recurse() -> () { + match database::Database::open( + &String::new(), + database::DatabaseMode::ReadOnly, + ) { + /* This will not happen without test data, but will force the compiler to compile + * the descend function. + */ + Ok(db) => { + let q = Query::create(db, &String::new()).unwrap(); + descend::<Query, super::Messages<Query>>(q.search_messages().unwrap()); + } + Err(err) => { + panic!("Got error while trying to open db: {:?}", err); + } + } + } +} |
