From acb67e3d7fef9e83e0be3150d42af3dd02e33fa6 Mon Sep 17 00:00:00 2001 From: "C. Morgan Hamill" Date: Thu, 19 Mar 2015 11:43:51 -0400 Subject: Add `NotmuchEnum` trait and `notmuch_enum!` macro. Implements enum types in pairs, specifying the type and variant names of each, like so: notmuch_enum! { pub enum enum_name => EnumName { variant_one => VariantOne, variant_two => VariantTwo } } Which expands to: pub enum enum_name { variant_one, variant_two } pub enum EnumName { VariantOne, VariantTwo } The `NotmuchEnum` trait also entails two functions to convert between the defined pairs, `from_notmuch_t()` and `to_notmuch_t()`. The macro takes care of their implementation, also. Yes, this is purely aesthetic whimsy: I wanted the types in the `ffi` module to match the types from the `notmuch.h` file, and I wanted the types I used within (and exported by) this crate to match the expected Rust convention. --- src/lib.rs | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/lib.rs') diff --git a/src/lib.rs b/src/lib.rs index 5c2fbd6..0f88f60 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,4 +1,8 @@ #![feature(libc)] extern crate libc; +#[macro_use] +mod macros; + mod ffi; +mod utils; -- cgit v1.2.1