diff options
| author | C. Morgan Hamill <me@cmhamill.org> | 2015-03-19 16:43:51 +0100 |
|---|---|---|
| committer | C. Morgan Hamill <me@cmhamill.org> | 2015-03-19 18:59:52 +0100 |
| commit | acb67e3d7fef9e83e0be3150d42af3dd02e33fa6 (patch) | |
| tree | d0114011907d5a137f0c118f9ef44dc1cd692b57 /src/lib.rs | |
| parent | a0f345202299b5f5214f1a791e896376e6cb7a04 (diff) | |
| download | mail-acb67e3d7fef9e83e0be3150d42af3dd02e33fa6.tar.gz | |
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.
Diffstat (limited to 'src/lib.rs')
| -rw-r--r-- | src/lib.rs | 4 |
1 files changed, 4 insertions, 0 deletions
@@ -1,4 +1,8 @@ #![feature(libc)] extern crate libc; +#[macro_use] +mod macros; + mod ffi; +mod utils; |
