diff options
| author | Austin Hellyer <[email protected]> | 2016-11-19 08:48:58 -0800 |
|---|---|---|
| committer | Austin Hellyer <[email protected]> | 2016-11-19 08:48:58 -0800 |
| commit | 7f24c706b36e8815c1d4f47de5257466cc281571 (patch) | |
| tree | 064653c56fc42d7fdac963120c4206b4151caa76 /src/client/dispatch.rs | |
| parent | Don't send embed on message edits if empty (diff) | |
| download | serenity-7f24c706b36e8815c1d4f47de5257466cc281571.tar.xz serenity-7f24c706b36e8815c1d4f47de5257466cc281571.zip | |
Fix cond. compile across multiple feature targets
Fixes conditional compilation across multiple combinations of feature
targets, where it was assumed a second feature would be enabled by
something that requires a feature to be enabled.
This also fixes an EOF compilation error on no-feature builds.
Diffstat (limited to 'src/client/dispatch.rs')
| -rw-r--r-- | src/client/dispatch.rs | 67 |
1 files changed, 41 insertions, 26 deletions
diff --git a/src/client/dispatch.rs b/src/client/dispatch.rs index 9aff46f..8798723 100644 --- a/src/client/dispatch.rs +++ b/src/client/dispatch.rs @@ -122,19 +122,20 @@ fn handle_event(event: Event, }, Event::CallDelete(event) => { if let Some(ref handler) = handler!(on_call_delete, event_store) { - let call = STATE - .lock() - .unwrap() - .calls - .remove(&event.channel_id); - update!(update_with_call_delete, event); - let context = context(None, conn, login_type); let handler = handler.clone(); - thread::spawn(move || { - (handler)(context, call); - }); + feature_state! {{ + let call = update!(update_with_call_delete, event); + + thread::spawn(move || { + (handler)(context, event.channel_id, call); + }); + } else { + thread::spawn(move || { + (handler)(context, event.channel_id); + }); + }} } else { update!(update_with_call_delete, event); } @@ -249,18 +250,25 @@ fn handle_event(event: Event, }, Event::ChannelUpdate(event) => { if let Some(ref handler) = handler!(on_channel_update, event_store) { - let before = STATE.lock() - .unwrap() - .find_channel(event.channel.id()); - update!(update_with_channel_update, event); let context = context(Some(event.channel.id()), conn, login_type); let handler = handler.clone(); - thread::spawn(move || { - (handler)(context, before, event.channel); - }); + feature_state! {{ + let before = STATE.lock() + .unwrap() + .find_channel(event.channel.id()); + update!(update_with_channel_update, event); + + thread::spawn(move || { + (handler)(context, before, event.channel); + }); + } else { + thread::spawn(move || { + (handler)(context, event.channel); + }); + }} } else { update!(update_with_channel_update, event); } @@ -516,18 +524,25 @@ fn handle_event(event: Event, }, Event::GuildUpdate(event) => { if let Some(ref handler) = handler!(on_guild_update, event_store) { - let before = STATE.lock() - .unwrap() - .guilds - .get(&event.guild.id) - .cloned(); - update!(update_with_guild_update, event); let context = context(None, conn, login_type); let handler = handler.clone(); - thread::spawn(move || { - (handler)(context, before, event.guild); - }); + feature_state! {{ + let before = STATE.lock() + .unwrap() + .guilds + .get(&event.guild.id) + .cloned(); + update!(update_with_guild_update, event); + + thread::spawn(move || { + (handler)(context, before, event.guild); + }); + } else { + thread::spawn(move || { + (handler)(context, event.guild); + }); + }} } else { update!(update_with_guild_update, event); } |