diff options
| author | Dirk Van Haerenborgh <vhdirk@gmail.com> | 2018-03-23 07:16:39 +0100 |
|---|---|---|
| committer | Dirk Van Haerenborgh <vhdirk@gmail.com> | 2018-03-23 07:16:39 +0100 |
| commit | be546fe6e4b709d1bb8770fdf0763ce4f494d0d6 (patch) | |
| tree | e08fb65667bdd1bd711c24f047a230b78f923936 /src | |
| parent | 8e76db5f75c9c315236bc6f8c6e195cec6103537 (diff) | |
| download | mail-be546fe6e4b709d1bb8770fdf0763ce4f494d0d6.tar.gz | |
improve lifetime definitions
Diffstat (limited to 'src')
| -rw-r--r-- | src/ffi.rs | 4 | ||||
| -rw-r--r-- | src/message.rs | 12 | ||||
| -rw-r--r-- | src/messages.rs | 16 | ||||
| -rw-r--r-- | src/thread.rs | 19 | ||||
| -rw-r--r-- | src/threads.rs | 16 |
5 files changed, 39 insertions, 28 deletions
@@ -54,6 +54,10 @@ impl notmuch_status_t { } } + pub fn is_err(&self) -> bool { + !self.is_ok() + } + pub fn as_result(self) -> Result<(), Self> { match self.is_ok() { true => Ok(()), diff --git a/src/message.rs b/src/message.rs index d774043..79fb19c 100644 --- a/src/message.rs +++ b/src/message.rs @@ -11,22 +11,22 @@ use ffi; use utils::{ NewFromPtr, }; -use Database; +use Query; #[derive(Debug)] -pub struct Message<'d>( +pub struct Message<'q, 'd:'q>( pub(crate) *mut ffi::notmuch_message_t, - marker::PhantomData<&'d mut Database>, + marker::PhantomData<&'q mut Query<'d>>, ); -impl<'d> NewFromPtr<*mut ffi::notmuch_message_t> for Message<'d> { - fn new(ptr: *mut ffi::notmuch_message_t) -> Message<'d> { +impl<'q, 'd> NewFromPtr<*mut ffi::notmuch_message_t> for Message<'q, 'd> { + fn new(ptr: *mut ffi::notmuch_message_t) -> Message<'q, 'd> { Message(ptr, marker::PhantomData) } } -impl<'d> ops::Drop for Message<'d> { +impl<'q, 'd> ops::Drop for Message<'q, 'd> { fn drop(&mut self) { unsafe { ffi::notmuch_message_destroy(self.0) diff --git a/src/messages.rs b/src/messages.rs index 706cfda..bb86866 100644 --- a/src/messages.rs +++ b/src/messages.rs @@ -10,24 +10,24 @@ use ffi; use utils::{ NewFromPtr, }; -use Database; +use Query; use Message; #[derive(Debug)] -pub struct Messages<'d>( +pub struct Messages<'q, 'd:'q>( // TODO: is this lifetime specifier correct? // query may outlive messages. pub(crate) *mut ffi::notmuch_messages_t, - marker::PhantomData<&'d mut Database>, + marker::PhantomData<&'q mut Query<'d>>, ); -impl<'d> NewFromPtr<*mut ffi::notmuch_messages_t> for Messages<'d> { - fn new(ptr: *mut ffi::notmuch_messages_t) -> Messages<'d> { +impl<'q, 'd> NewFromPtr<*mut ffi::notmuch_messages_t> for Messages<'q, 'd> { + fn new(ptr: *mut ffi::notmuch_messages_t) -> Messages<'q, 'd> { Messages(ptr, marker::PhantomData) } } -impl<'d> ops::Drop for Messages<'d> { +impl<'q, 'd> ops::Drop for Messages<'q, 'd> { fn drop(&mut self) { unsafe { ffi::notmuch_messages_destroy(self.0) @@ -35,8 +35,8 @@ impl<'d> ops::Drop for Messages<'d> { } } -impl<'d> iter::Iterator for Messages<'d> { - type Item = Message<'d>; +impl<'q, 'd> iter::Iterator for Messages<'q, 'd> { + type Item = Message<'q, 'd>; fn next(&mut self) -> Option<Self::Item> { diff --git a/src/thread.rs b/src/thread.rs index 980ff39..cf5440c 100644 --- a/src/thread.rs +++ b/src/thread.rs @@ -11,21 +11,28 @@ use ffi; use utils::{ NewFromPtr, }; -use Database; +use Query; #[derive(Debug)] -pub struct Thread<'d>( +pub struct Thread<'q, 'd:'q>( pub(crate) *mut ffi::notmuch_thread_t, - marker::PhantomData<&'d mut Database>, + marker::PhantomData<&'q mut Query<'d>>, ); -impl<'d> NewFromPtr<*mut ffi::notmuch_thread_t> for Thread<'d> { - fn new(ptr: *mut ffi::notmuch_thread_t) -> Thread<'d> { +impl<'q, 'd> NewFromPtr<*mut ffi::notmuch_thread_t> for Thread<'q, 'd> { + fn new(ptr: *mut ffi::notmuch_thread_t) -> Thread<'q, 'd> { Thread(ptr, marker::PhantomData) } } -impl<'d> ops::Drop for Thread<'d> { +// impl<'d> Thread<'d>( +// +// +// +// }; +// + +impl<'q, 'd> ops::Drop for Thread<'q, 'd> { fn drop(&mut self) { unsafe { ffi::notmuch_thread_destroy(self.0) diff --git a/src/threads.rs b/src/threads.rs index 5f62a8d..eb8452e 100644 --- a/src/threads.rs +++ b/src/threads.rs @@ -8,23 +8,23 @@ use utils::{ NewFromPtr, }; -use Database; +use Query; use Thread; use ffi; #[derive(Debug)] -pub struct Threads<'d>( +pub struct Threads<'q, 'd:'q>( *mut ffi::notmuch_threads_t, - marker::PhantomData<&'d mut Database>, + marker::PhantomData<&'q mut Query<'d>>, ); -impl<'d> NewFromPtr<*mut ffi::notmuch_threads_t> for Threads<'d> { - fn new(ptr: *mut ffi::notmuch_threads_t) -> Threads<'d> { +impl<'q, 'd> NewFromPtr<*mut ffi::notmuch_threads_t> for Threads<'q, 'd> { + fn new(ptr: *mut ffi::notmuch_threads_t) -> Threads<'q, 'd> { Threads(ptr, marker::PhantomData) } } -impl<'d> ops::Drop for Threads<'d> { +impl<'q, 'd> ops::Drop for Threads<'q, 'd> { fn drop(&mut self) { unsafe { ffi::notmuch_threads_destroy(self.0) @@ -32,8 +32,8 @@ impl<'d> ops::Drop for Threads<'d> { } } -impl<'d> iter::Iterator for Threads<'d> { - type Item = Thread<'d>; +impl<'q, 'd> iter::Iterator for Threads<'q, 'd> { + type Item = Thread<'q, 'd>; fn next(&mut self) -> Option<Self::Item> { |
