diff options
| author | Dirk Van Haerenborgh <vhdirk@gmail.com> | 2018-12-20 08:21:03 +0100 |
|---|---|---|
| committer | Dirk Van Haerenborgh <vhdirk@gmail.com> | 2018-12-20 08:21:03 +0100 |
| commit | bb8a60ddc9fdecc6c1004639514b538578e37532 (patch) | |
| tree | 634968cabab56edec2f8a750903c155800a0f031 /src/messages.rs | |
| parent | 2baa9d13ad4c5c2c6e55b6ca49c92a4d2434fba7 (diff) | |
| download | mail-bb8a60ddc9fdecc6c1004639514b538578e37532.tar.gz | |
remove ptr indirection
Diffstat (limited to 'src/messages.rs')
| -rw-r--r-- | src/messages.rs | 32 |
1 files changed, 15 insertions, 17 deletions
diff --git a/src/messages.rs b/src/messages.rs index db92f73..01e0ea4 100644 --- a/src/messages.rs +++ b/src/messages.rs @@ -8,25 +8,23 @@ use Tags; use TagsOwner; #[derive(Debug)] -pub struct MessagesPtr { - pub ptr: *mut ffi::notmuch_messages_t, -} - -impl Drop for MessagesPtr { - fn drop(self: &mut Self) { - unsafe { ffi::notmuch_messages_destroy(self.ptr) }; - } -} - -#[derive(Debug)] pub struct Messages<'o, O> where O: MessageOwner + 'o, { - pub(crate) handle: MessagesPtr, + pub(crate) ptr: *mut ffi::notmuch_messages_t, marker: ScopedPhantomcow<'o, O>, } +impl<'o, O> Drop for Messages<'o, O> +where + O: MessageOwner + 'o, +{ + fn drop(self: &mut Self) { + unsafe { ffi::notmuch_messages_destroy(self.ptr) }; + } +} + impl<'o, O> Messages<'o, O> where O: MessageOwner + 'o, @@ -36,7 +34,7 @@ where P: Into<ScopedPhantomcow<'o, O>>, { Messages { - handle: MessagesPtr { ptr }, + ptr, marker: owner.into(), } } @@ -64,7 +62,7 @@ where */ pub fn collect_tags<'m>(self: &'o Self) -> Tags<'m, Self> { Tags::from_ptr( - unsafe { ffi::notmuch_messages_collect_tags(self.handle.ptr) }, + unsafe { ffi::notmuch_messages_collect_tags(self.ptr) }, self, ) } @@ -77,15 +75,15 @@ where type Item = Message<'o, O>; fn next(&mut self) -> Option<Self::Item> { - let valid = unsafe { ffi::notmuch_messages_valid(self.handle.ptr) }; + let valid = unsafe { ffi::notmuch_messages_valid(self.ptr) }; if valid == 0 { return None; } let cthrd = unsafe { - let thrd = ffi::notmuch_messages_get(self.handle.ptr); - ffi::notmuch_messages_move_to_next(self.handle.ptr); + let thrd = ffi::notmuch_messages_get(self.ptr); + ffi::notmuch_messages_move_to_next(self.ptr); thrd }; |
