From e4523dd5d6e2fe3f9afa99671baadfdf8eef5385 Mon Sep 17 00:00:00 2001 From: "C. Morgan Hamill" Date: Thu, 26 Mar 2015 14:41:54 -0400 Subject: Remove `NotmuchType` trait. No longer necessary with the `From` and `Into` traits from std::convert. --- src/database.rs | 3 +-- src/error.rs | 3 +-- src/ffi.rs | 3 +-- src/macros.rs | 12 ++++++------ src/utils.rs | 7 ------- 5 files changed, 9 insertions(+), 19 deletions(-) (limited to 'src') 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 = result::Result; @@ -52,6 +51,6 @@ impl error::FromError for Error { impl error::FromError 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)) } } diff --git a/src/ffi.rs b/src/ffi.rs index 1ee940a..871cefd 100644 --- a/src/ffi.rs +++ b/src/ffi.rs @@ -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; } -- cgit v1.2.1