From bed2b54ea403872b7e540ade251e9609090a7cf5 Mon Sep 17 00:00:00 2001 From: eaon Date: Wed, 21 Nov 2018 11:30:36 -0500 Subject: Use the ? operator instead of the try! macro --- src/query.rs | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) (limited to 'src/query.rs') diff --git a/src/query.rs b/src/query.rs index c73d4ca..38711e9 100644 --- a/src/query.rs +++ b/src/query.rs @@ -82,7 +82,7 @@ impl<'d> Query<'d> { pub fn count_messages(self: &Self) -> Result { let mut cnt = 0; - try!(unsafe { ffi::notmuch_query_count_messages(self.handle.ptr, &mut cnt,) }.as_result()); + unsafe { ffi::notmuch_query_count_messages(self.handle.ptr, &mut cnt) }.as_result()?; Ok(cnt) } @@ -93,7 +93,7 @@ impl<'d> Query<'d> { pub fn count_threads(self: &Self) -> Result { let mut cnt = 0; - try!(unsafe { ffi::notmuch_query_count_threads(self.handle.ptr, &mut cnt,) }.as_result()); + unsafe { ffi::notmuch_query_count_threads(self.handle.ptr, &mut cnt) }.as_result()?; Ok(cnt) } @@ -107,10 +107,8 @@ pub trait QueryExt<'d> { let queryref = query.into(); let mut thrds = ptr::null_mut(); - try!( - unsafe { ffi::notmuch_query_search_threads(queryref.handle.ptr, &mut thrds) } - .as_result() - ); + unsafe { ffi::notmuch_query_search_threads(queryref.handle.ptr, &mut thrds) } + .as_result()?; Ok(Threads::from_ptr(thrds, Supercow::phantom(queryref))) } @@ -122,10 +120,8 @@ pub trait QueryExt<'d> { let queryref = query.into(); let mut msgs = ptr::null_mut(); - try!( - unsafe { ffi::notmuch_query_search_messages(queryref.handle.ptr, &mut msgs) } - .as_result() - ); + unsafe { ffi::notmuch_query_search_messages(queryref.handle.ptr, &mut msgs) } + .as_result()?; Ok(Messages::from_ptr(msgs, Supercow::phantom(queryref))) } -- cgit v1.2.1