aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--README.md2
-rw-r--r--src/messages.rs32
2 files changed, 33 insertions, 1 deletions
diff --git a/README.md b/README.md
index 7c7811d..8f2e9e8 100644
--- a/README.md
+++ b/README.md
@@ -5,7 +5,7 @@ This is not much more than a wrapper for the [notmuch](https://notmuchmail.org/)
[![Build Status](https://travis-ci.org/vhdirk/notmuch-rs.svg?branch=master)](https://travis-ci.org/vhdirk/notmuch-rs)
[![Crate version](https://img.shields.io/crates/v/notmuch.svg)](https://crates.io/crates/notmuch)
[![Download statistics](https://img.shields.io/crates/d/notmuch.svg)](https://crates.io/crates/notmuch)
-[![License](https://img.shields.io/crates/l/notmuch.svg)](https://crates.io/crates/notmuch)
+[![License](https://img.shields.io/crates/l/notmuch.svg)](https://crates.io/crates/notmuch) [![Join the chat at https://gitter.im/notmuch-rs/Lobby](https://badges.gitter.im/notmuch-rs/Lobby.svg)](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);
+ }
+ }
+ }
+}