From dada4a5f126f79cc0bb7376343ceeb2575a65969 Mon Sep 17 00:00:00 2001 From: Dirk Van Haerenborgh Date: Fri, 23 Mar 2018 14:14:36 +0100 Subject: lifetime parameters are cool --- src/database.rs | 10 +++++----- src/messages.rs | 2 +- src/query.rs | 4 ++-- src/threads.rs | 4 ++-- 4 files changed, 10 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/database.rs b/src/database.rs index b0e8b75..c212745 100644 --- a/src/database.rs +++ b/src/database.rs @@ -171,7 +171,7 @@ impl Database { Ok(()) } - pub fn directory>(&self, path: &P) -> Result> { + pub fn directory<'d, P: AsRef>(&self, path: &P) -> Result>> { let path_str = CString::new(path.as_ref().to_str().unwrap()).unwrap(); let mut dir = ptr::null_mut(); @@ -182,12 +182,12 @@ impl Database { }.as_result()); match dir.is_null() { - false => Ok(None), - true => Ok(Some(Directory::new(dir))), + true => Ok(None), + false => Ok(Some(Directory::new(dir))), } } - pub fn create_query(&self, query_string: &String) -> Result { + pub fn create_query<'d>(&self, query_string: &String) -> Result> { let query_str = CString::new(query_string.as_str()).unwrap(); println!("query {:?}", query_str); let mut query = ptr::null_mut(); @@ -198,7 +198,7 @@ impl Database { Ok(Query::new(query)) } - pub fn all_tags(&self) -> Result { + pub fn all_tags<'d>(&self) -> Result> { let mut tags = ptr::null_mut(); unsafe { diff --git a/src/messages.rs b/src/messages.rs index 8466387..9a539c9 100644 --- a/src/messages.rs +++ b/src/messages.rs @@ -64,6 +64,6 @@ impl<'q, 'd> iter::Iterator for Messages<'q, 'd> { ffi::notmuch_messages_get(self.0) }; - Some(Message::new(cmsg)) + Some(Self::Item::new(cmsg)) } } diff --git a/src/query.rs b/src/query.rs index bedd758..1fe4e0d 100644 --- a/src/query.rs +++ b/src/query.rs @@ -51,7 +51,7 @@ impl<'d> Query<'d> { /// Filter messages according to the query and return - pub fn search_messages(self: &Self) -> Result + pub fn search_messages<'q>(self: &Self) -> Result> { let mut msgs = ptr::null_mut(); try!(unsafe { @@ -75,7 +75,7 @@ impl<'d> Query<'d> { return Ok(cnt); } - pub fn search_threads(self: &Self) -> Result + pub fn search_threads<'q>(self: &Self) -> Result> { let mut thrds = ptr::null_mut(); try!(unsafe { diff --git a/src/threads.rs b/src/threads.rs index eb8452e..dadb137 100644 --- a/src/threads.rs +++ b/src/threads.rs @@ -42,7 +42,7 @@ impl<'q, 'd> iter::Iterator for Threads<'q, 'd> { }; if valid == 0{ - return None + return None; } let cthread = unsafe { @@ -50,6 +50,6 @@ impl<'q, 'd> iter::Iterator for Threads<'q, 'd> { ffi::notmuch_threads_get(self.0) }; - Some(Thread::new(cthread)) + Some(Self::Item::new(cthread)) } } -- cgit v1.2.1