From bb8a60ddc9fdecc6c1004639514b538578e37532 Mon Sep 17 00:00:00 2001 From: Dirk Van Haerenborgh Date: Thu, 20 Dec 2018 08:21:03 +0100 Subject: remove ptr indirection --- src/directory.rs | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) (limited to 'src/directory.rs') diff --git a/src/directory.rs b/src/directory.rs index 1aff32b..8f09ed7 100644 --- a/src/directory.rs +++ b/src/directory.rs @@ -7,23 +7,19 @@ use Filenames; use FilenamesOwner; use utils::{ScopedSupercow, ScopedPhantomcow}; + #[derive(Debug)] -pub(crate) struct DirectoryPtr { - pub ptr: *mut ffi::notmuch_directory_t, +pub struct Directory<'d> { + ptr: *mut ffi::notmuch_directory_t, + marker: ScopedPhantomcow<'d, Database>, } -impl Drop for DirectoryPtr { +impl<'d> Drop for Directory<'d> { fn drop(&mut self) { unsafe { ffi::notmuch_directory_destroy(self.ptr) }; } } -#[derive(Debug)] -pub struct Directory<'d> { - handle: DirectoryPtr, - marker: ScopedPhantomcow<'d, Database>, -} - impl<'d> FilenamesOwner for Directory<'d> {} impl<'d> Directory<'d> { @@ -32,7 +28,7 @@ impl<'d> Directory<'d> { O: Into>, { Directory { - handle: DirectoryPtr { ptr }, + ptr, marker: owner.into(), } } @@ -49,7 +45,7 @@ pub trait DirectoryExt<'d> { { let dir = directory.into(); Filenames::from_ptr( - unsafe { ffi::notmuch_directory_get_child_directories(dir.handle.ptr) }, + unsafe { ffi::notmuch_directory_get_child_directories(dir.ptr) }, Supercow::phantom(dir), ) } -- cgit v1.2.1