diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/database.rs | 15 | ||||
| -rw-r--r-- | src/ffi.rs | 5 | ||||
| -rw-r--r-- | src/lib.rs | 3 | ||||
| -rw-r--r-- | src/message.rs | 7 | ||||
| -rw-r--r-- | src/messages.rs | 2 | ||||
| -rw-r--r-- | src/query.rs | 7 | ||||
| -rw-r--r-- | src/tags.rs | 1 | ||||
| -rw-r--r-- | src/thread.rs | 12 |
8 files changed, 16 insertions, 36 deletions
diff --git a/src/database.rs b/src/database.rs index 70e7ebb..2b95a7a 100644 --- a/src/database.rs +++ b/src/database.rs @@ -181,26 +181,23 @@ impl Database { ) }.as_result()); - match dir.is_null() { - true => Ok(None), - false => Ok(Some(Directory::new(dir))), - } + if dir.is_null() { Ok(None) } else { Ok(Some(Directory::new(dir))) } } - pub fn create_query<'d>(&'d self, query_string: &String) -> Result<Query<'d>> { - let query_str = CString::new(query_string.as_str()).unwrap(); + pub fn create_query<'d>(&'d self, query_string: &str) -> Result<Query<'d>> { + let query_str = CString::new(query_string).unwrap(); println!("query {:?}", query_str); - let mut query = unsafe { + let query = unsafe { ffi::notmuch_query_create(self.0, query_str.as_ptr()) }; Ok(Query::new(query)) } - pub fn all_tags<'d>(&'d self) -> Result<Tags<'d>> { + pub fn all_tags<'d>(&self) -> Result<Tags<'d>> { - let mut tags = unsafe { + let tags = unsafe { ffi::notmuch_database_get_all_tags(self.0) }; @@ -59,10 +59,7 @@ impl notmuch_status_t { } pub fn as_result(self) -> Result<(), Self> { - match self.is_ok() { - true => Ok(()), - false => Err(self), - } + if self.is_ok() { Ok(()) } else { Err(self) } } } @@ -1,3 +1,6 @@ +#![cfg_attr(feature="clippy", feature(plugin))] +#![cfg_attr(feature="clippy", plugin(clippy))] + #[macro_use] mod macros; diff --git a/src/message.rs b/src/message.rs index 05effd2..60011d1 100644 --- a/src/message.rs +++ b/src/message.rs @@ -1,15 +1,10 @@ -use std; use std::{ ops, - marker, - str, - result + marker }; use std::path::PathBuf; -use error::Result; - use ffi; use utils::{ NewFromPtr, diff --git a/src/messages.rs b/src/messages.rs index 3ef39e9..1d3b3c2 100644 --- a/src/messages.rs +++ b/src/messages.rs @@ -4,8 +4,6 @@ use std::{ iter }; -use error::Result; - use ffi; use utils::{ NewFromPtr, diff --git a/src/query.rs b/src/query.rs index b84d321..125e63d 100644 --- a/src/query.rs +++ b/src/query.rs @@ -1,4 +1,3 @@ -use std; use std::{ ops, marker, @@ -24,7 +23,7 @@ pub struct Query<'d>( impl<'d> Query<'d> { - pub fn create(db: &'d Database, query_string: &String) -> Result<Self> { + pub fn create(db: &'d Database, query_string: &str) -> Result<Self> { db.create_query(query_string) } @@ -72,7 +71,7 @@ impl<'d> Query<'d> { ) }.as_result()); - return Ok(cnt); + Ok(cnt) } pub fn search_threads<'q>(self: &'d Self) -> Result<Threads<'q, 'd>> @@ -96,7 +95,7 @@ impl<'d> Query<'d> { ) }.as_result()); - return Ok(cnt); + Ok(cnt) } } diff --git a/src/tags.rs b/src/tags.rs index cc5b05f..02ee767 100644 --- a/src/tags.rs +++ b/src/tags.rs @@ -5,7 +5,6 @@ use std::{ }; use std::ffi::{ - CString, CStr }; diff --git a/src/thread.rs b/src/thread.rs index ee19c7e..47166d4 100644 --- a/src/thread.rs +++ b/src/thread.rs @@ -1,15 +1,7 @@ -use std; use std::{ ops, - marker, - str, - result + marker }; -use std::sync::atomic::AtomicPtr; - -use std::ffi::{CString, CStr}; - -use error::Result; use ffi; use utils::{ @@ -89,7 +81,7 @@ impl<'q, 'd> Thread<'q, 'd>{ ffi::notmuch_thread_get_authors(self.0) }; - athrs.to_str().unwrap().split(",").map(|s| s.to_string()).collect() + athrs.to_str().unwrap().split(',').map(|s| s.to_string()).collect() } /// Get the date of the oldest message in 'thread' as a time_t value. |
