diff options
| author | Zeyla Hellyer <[email protected]> | 2017-09-18 10:47:19 -0700 |
|---|---|---|
| committer | Zeyla Hellyer <[email protected]> | 2017-09-18 17:48:37 -0700 |
| commit | 8e3b4d601ffb78909db859640482f7e0bb10131f (patch) | |
| tree | 16500c9274a0517a776ea707bb623d1c9947d8cf /src/client/dispatch.rs | |
| parent | Apply rustfmt (diff) | |
| download | serenity-8e3b4d601ffb78909db859640482f7e0bb10131f.tar.xz serenity-8e3b4d601ffb78909db859640482f7e0bb10131f.zip | |
Fix compiles of a variety of feature combinations
This fixes compilation errors and warnings when compiling a mixture of
non-default feature targets.
Diffstat (limited to 'src/client/dispatch.rs')
| -rw-r--r-- | src/client/dispatch.rs | 36 |
1 files changed, 13 insertions, 23 deletions
diff --git a/src/client/dispatch.rs b/src/client/dispatch.rs index bda0677..04739b6 100644 --- a/src/client/dispatch.rs +++ b/src/client/dispatch.rs @@ -1,18 +1,23 @@ -use std::sync::{self, Arc}; +use std::sync::Arc; use parking_lot::Mutex; -use std::thread; -use std::time; use super::event_handler::EventHandler; use super::Context; use typemap::ShareMap; use gateway::Shard; use model::event::Event; -use model::{Channel, GuildId, Message}; -use chrono::{Timelike, Utc}; +use model::{Channel, Message}; use tokio_core::reactor::Handle; +#[cfg(feature = "cache")] +use chrono::{Timelike, Utc}; #[cfg(feature = "framework")] use framework::Framework; +#[cfg(feature = "cache")] +use model::GuildId; +#[cfg(feature = "cache")] +use std::{thread, time}; +#[cfg(feature = "framework")] +use std::sync; #[cfg(feature = "cache")] use super::CACHE; @@ -28,6 +33,7 @@ macro_rules! update { }; } +#[cfg(feature = "cache")] macro_rules! now { () => (Utc::now().time().second() * 1000) } @@ -36,16 +42,6 @@ fn context(conn: &Arc<Mutex<Shard>>, data: &Arc<Mutex<ShareMap>>, handle: &Handl Context::new(conn.clone(), data.clone(), handle.clone()) } -#[cfg(feature = "standard_framework")] -macro_rules! helper { - ($enabled:block else $disabled:block) => { $enabled } -} - -#[cfg(not(feature = "standard_framework"))] -macro_rules! helper { - ($enabled:block else $disabled:block) => { $disabled } -} - #[cfg(feature = "framework")] pub fn dispatch<H: EventHandler + 'static>(event: Event, conn: &Arc<Mutex<Shard>>, @@ -64,13 +60,7 @@ pub fn dispatch<H: EventHandler + 'static>(event: Event, ); if let Some(ref mut framework) = *framework.lock().unwrap() { - helper! {{ - if framework.initialized() { - framework.dispatch(context, event.message, tokio_handle); - } - } else { framework.dispatch(context, event.message, tokio_handle); - }} } }, other => handle_event(other, conn, data, event_handler, tokio_handle), @@ -116,10 +106,10 @@ fn handle_event<H: EventHandler + 'static>(event: Event, data: &Arc<Mutex<ShareMap>>, event_handler: &Arc<H>, tokio_handle: &Handle) { - #[cfg(feature="cache")] + #[cfg(feature = "cache")] let mut last_guild_create_time = now!(); - #[cfg(feature="cache")] + #[cfg(feature = "cache")] let wait_for_guilds = move || -> ::Result<()> { let unavailable_guilds = CACHE.read().unwrap().unavailable_guilds.len(); |