diff options
Diffstat (limited to 'src/threads.rs')
| -rw-r--r-- | src/threads.rs | 30 |
1 files changed, 14 insertions, 16 deletions
diff --git a/src/threads.rs b/src/threads.rs index 6d1e8e4..0359e20 100644 --- a/src/threads.rs +++ b/src/threads.rs @@ -7,25 +7,23 @@ use utils::ScopedPhantomcow; #[derive(Debug)] -pub(crate) struct ThreadsPtr { - pub ptr: *mut ffi::notmuch_threads_t, -} - -impl Drop for ThreadsPtr { - fn drop(&mut self) { - unsafe { ffi::notmuch_threads_destroy(self.ptr) }; - } -} - -#[derive(Debug)] pub struct Threads<'d, 'q> where 'd: 'q { - handle: ThreadsPtr, + ptr: *mut ffi::notmuch_threads_t, marker: ScopedPhantomcow<'q, Query<'d>>, } +impl<'d, 'q> Drop for Threads<'d, 'q> +where + 'd: 'q, +{ + fn drop(&mut self) { + unsafe { ffi::notmuch_threads_destroy(self.ptr) }; + } +} + impl<'d, 'q> Threads<'d, 'q> where 'd: 'q, @@ -35,7 +33,7 @@ where P: Into<ScopedPhantomcow<'q, Query<'d>>>, { Threads { - handle: ThreadsPtr { ptr }, + ptr, marker: owner.into(), } } @@ -48,15 +46,15 @@ where type Item = Thread<'d, 'q>; fn next(&mut self) -> Option<Self::Item> { - let valid = unsafe { ffi::notmuch_threads_valid(self.handle.ptr) }; + let valid = unsafe { ffi::notmuch_threads_valid(self.ptr) }; if valid == 0 { return None; } let cthrd = unsafe { - let thrd = ffi::notmuch_threads_get(self.handle.ptr); - ffi::notmuch_threads_move_to_next(self.handle.ptr); + let thrd = ffi::notmuch_threads_get(self.ptr); + ffi::notmuch_threads_move_to_next(self.ptr); thrd }; |
