aboutsummaryrefslogtreecommitdiff
path: root/src/utils
diff options
context:
space:
mode:
authorZeyla Hellyer <[email protected]>2017-09-18 10:47:19 -0700
committerZeyla Hellyer <[email protected]>2017-09-18 17:48:37 -0700
commit8e3b4d601ffb78909db859640482f7e0bb10131f (patch)
tree16500c9274a0517a776ea707bb623d1c9947d8cf /src/utils
parentApply rustfmt (diff)
downloadserenity-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/utils')
-rw-r--r--src/utils/mod.rs5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/utils/mod.rs b/src/utils/mod.rs
index 180fa2d..d81b0f9 100644
--- a/src/utils/mod.rs
+++ b/src/utils/mod.rs
@@ -19,7 +19,10 @@ use std::io::Read;
use std::path::Path;
use internal::prelude::*;
use model::{EmojiId, EmojiIdentifier};
+
+#[cfg(feature = "cache")]
use cache::Cache;
+#[cfg(feature = "cache")]
use CACHE;
/// Determines if a name is NSFW.
@@ -449,6 +452,7 @@ pub fn shard_id(guild_id: u64, shard_count: u64) -> u64 { (guild_id >> 22) % sha
/// // assuming that the id is `1234`:
/// assert_eq!(1234, utils::with_cache(|cache| cache.user.id));
/// ```
+#[cfg(feature = "cache")]
pub fn with_cache<T, F>(f: F) -> T
where F: Fn(&Cache) -> T {
let cache = CACHE.read().unwrap();
@@ -469,6 +473,7 @@ pub fn with_cache<T, F>(f: F) -> T
/// ```
///
/// [`with_cache`]: #fn.with_cache
+#[cfg(feature = "cache")]
pub fn with_cache_mut<T, F>(mut f: F) -> T
where F: FnMut(&mut Cache) -> T {
let mut cache = CACHE.write().unwrap();