aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Cargo.toml1
-rw-r--r--src/database.rs15
-rw-r--r--src/ffi.rs5
-rw-r--r--src/lib.rs3
-rw-r--r--src/message.rs7
-rw-r--r--src/messages.rs2
-rw-r--r--src/query.rs7
-rw-r--r--src/tags.rs1
-rw-r--r--src/thread.rs12
9 files changed, 17 insertions, 36 deletions
diff --git a/Cargo.toml b/Cargo.toml
index 70a82e1..d846862 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -13,6 +13,7 @@ travis-ci = { repository = "vhdirk/notmuch-rs" }
[dependencies]
libc = "0.2"
+clippy = { version = "0.0.193", optional = true }
[[test]]
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)
};
diff --git a/src/ffi.rs b/src/ffi.rs
index 63c83ba..3c281fa 100644
--- a/src/ffi.rs
+++ b/src/ffi.rs
@@ -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) }
}
}
diff --git a/src/lib.rs b/src/lib.rs
index 0c807f4..db3c276 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -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.