diff options
| author | C. Morgan Hamill <me@cmhamill.org> | 2015-03-26 19:41:54 +0100 |
|---|---|---|
| committer | C. Morgan Hamill <me@cmhamill.org> | 2015-03-26 19:41:54 +0100 |
| commit | e4523dd5d6e2fe3f9afa99671baadfdf8eef5385 (patch) | |
| tree | 6977dbec192d49852fa57e5f9281a8a8c88febfa | |
| parent | a2300c78a747124003c8415b805712aed31e4959 (diff) | |
| download | mail-e4523dd5d6e2fe3f9afa99671baadfdf8eef5385.tar.gz | |
Remove `NotmuchType` trait.
No longer necessary with the `From` and `Into` traits from std::convert.
| -rw-r--r-- | src/database.rs | 3 | ||||
| -rw-r--r-- | src/error.rs | 3 | ||||
| -rw-r--r-- | src/ffi.rs | 3 | ||||
| -rw-r--r-- | src/macros.rs | 12 | ||||
| -rw-r--r-- | src/utils.rs | 7 |
5 files changed, 9 insertions, 19 deletions
diff --git a/src/database.rs b/src/database.rs index 6b0542d..d082f3a 100644 --- a/src/database.rs +++ b/src/database.rs @@ -8,7 +8,6 @@ use libc; use error::Result; use utils::{ - NotmuchType, ToCString, ToStr, }; @@ -41,7 +40,7 @@ impl Database { let mut db = ptr::null_mut(); try!(unsafe { ffi::notmuch_database_open( - path.as_ptr(), mode.to_notmuch_t(), &mut db, + path.as_ptr(), mode.into(), &mut db, ) }.as_result()); diff --git a/src/error.rs b/src/error.rs index 22c1f6e..01c28fb 100644 --- a/src/error.rs +++ b/src/error.rs @@ -5,7 +5,6 @@ use std::{ result, }; -use utils::NotmuchType; use ffi; pub type Result<T> = result::Result<T, Error>; @@ -52,6 +51,6 @@ impl error::FromError<ffi::NotmuchStatus> for Error { impl error::FromError<ffi::notmuch_status_t> for Error { fn from_error(err: ffi::notmuch_status_t) -> Error { - Error::NotmuchError(ffi::NotmuchStatus::from_notmuch_t(err)) + Error::NotmuchError(ffi::NotmuchStatus::from(err)) } } @@ -18,7 +18,6 @@ use std::{ }; use utils::{ - NotmuchType, ToStr, }; @@ -68,7 +67,7 @@ impl notmuch_status_t { impl ToStr for NotmuchStatus { fn to_str<'a>(&self) -> Result<&'a str, str::Utf8Error> { unsafe { - notmuch_status_to_string(self.to_notmuch_t()) + notmuch_status_to_string((*self).into()) }.to_str() } } diff --git a/src/macros.rs b/src/macros.rs index 8802a71..a36197b 100644 --- a/src/macros.rs +++ b/src/macros.rs @@ -16,16 +16,16 @@ macro_rules! notmuch_enum { $($variant_alias),* } - impl NotmuchType for $name_alias { - type NotmuchT = $name; - - fn from_notmuch_t(notmuch_t: $name) -> Self { - match notmuch_t { + impl From<$name> for $name_alias { + fn from(t: $name) -> Self { + match t { $($name::$variant => $name_alias::$variant_alias),* } } + } - fn to_notmuch_t(self) -> $name { + impl Into<$name> for $name_alias { + fn into(self) -> $name { match self { $($name_alias::$variant_alias => $name::$variant),* } diff --git a/src/utils.rs b/src/utils.rs index ec5b5b3..b5acb66 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -8,13 +8,6 @@ use std::os::unix::ffi::OsStrExt; use libc; -pub trait NotmuchType { - type NotmuchT; - - fn from_notmuch_t(notmuch_t: Self::NotmuchT) -> Self; - fn to_notmuch_t(self) -> Self::NotmuchT; -} - pub trait ToCString { fn to_cstring(&self) -> Result<ffi::CString, ffi::NulError>; } |
