From 39aba7b077f0285bd31298d2c270e11409252937 Mon Sep 17 00:00:00 2001 From: Dirk Van Haerenborgh Date: Fri, 23 Mar 2018 10:27:46 +0100 Subject: the iterator can handle null pointers --- src/query.rs | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/src/query.rs b/src/query.rs index 36e9be6..bedd758 100644 --- a/src/query.rs +++ b/src/query.rs @@ -51,7 +51,7 @@ impl<'d> Query<'d> { /// Filter messages according to the query and return - pub fn search_messages(self: &Self) -> Result> + pub fn search_messages(self: &Self) -> Result { let mut msgs = ptr::null_mut(); try!(unsafe { @@ -60,10 +60,7 @@ impl<'d> Query<'d> { ) }.as_result()); - match msgs.is_null() { - false => Ok(None), - true => Ok(Some(Messages::new(msgs))), - } + Ok(Messages::new(msgs)) } pub fn count_messages(self: &Self) -> Result @@ -78,7 +75,7 @@ impl<'d> Query<'d> { return Ok(cnt); } - pub fn search_threads(self: &Self) -> Result> + pub fn search_threads(self: &Self) -> Result { let mut thrds = ptr::null_mut(); try!(unsafe { @@ -87,10 +84,7 @@ impl<'d> Query<'d> { ) }.as_result()); - match thrds.is_null() { - false => Ok(None), - true => Ok(Some(Threads::new(thrds))), - } + Ok(Threads::new(thrds)) } pub fn count_threads(self: &Self) -> Result -- cgit v1.2.1