diff options
| author | Zeyla Hellyer <[email protected]> | 2018-08-07 09:24:07 -0700 |
|---|---|---|
| committer | Zeyla Hellyer <[email protected]> | 2018-08-07 09:25:06 -0700 |
| commit | 39bb75cc6759ceb972c0caca0b03c7971a445eb8 (patch) | |
| tree | 343d97399ea597804f0cd30016034c4adb8efebe /src/model/channel | |
| parent | Fix some documentation spacing (diff) | |
| download | serenity-39bb75cc6759ceb972c0caca0b03c7971a445eb8.tar.xz serenity-39bb75cc6759ceb972c0caca0b03c7971a445eb8.zip | |
Fix compilation + tests on certain feature combos
On certain feature combinations, compilation and tests would not function
correctly.
This commit goes through a number of feature combinations and gates some tests
behind the required features and fixes other compilation errors.
Diffstat (limited to 'src/model/channel')
| -rw-r--r-- | src/model/channel/mod.rs | 42 |
1 files changed, 37 insertions, 5 deletions
diff --git a/src/model/channel/mod.rs b/src/model/channel/mod.rs index 9b350e5..5ba9a87 100644 --- a/src/model/channel/mod.rs +++ b/src/model/channel/mod.rs @@ -69,9 +69,13 @@ impl Channel { /// /// ```rust,no_run /// # extern crate serenity; + /// # /// # use self::serenity::model::id::ChannelId; + /// # + /// # #[cfg(feature = "model")] /// # fn main() { - /// # let channel = ChannelId(0).get().unwrap(); + /// # let channel = ChannelId(0).get().unwrap(); + /// # /// match channel.group() { /// Some(group_lock) => { /// if let Some(ref name) = group_lock.read().name { @@ -82,7 +86,11 @@ impl Channel { /// }, /// None => { println!("It's not a group!"); }, /// } + /// # /// # } + /// # + /// # #[cfg(not(feature = "model"))] + /// fn main() {} /// ``` pub fn group(self) -> Option<Arc<RwLock<Group>>> { match self { @@ -103,16 +111,24 @@ impl Channel { /// /// ```rust,no_run /// # extern crate serenity; + /// # /// # use self::serenity::model::id::ChannelId; + /// # + /// # #[cfg(feature = "model")] /// # fn main() { - /// let channel = ChannelId(0).get().unwrap(); + /// # let channel = ChannelId(0).get().unwrap(); + /// # /// match channel.guild() { /// Some(guild_lock) => { /// println!("It's a guild named {}!", guild_lock.read().name); /// }, /// None => { println!("It's not a guild!"); }, /// } + /// # /// # } + /// # + /// # #[cfg(not(feature = "model"))] + /// fn main() {} /// ``` pub fn guild(self) -> Option<Arc<RwLock<GuildChannel>>> { match self { @@ -133,9 +149,13 @@ impl Channel { /// /// ```rust,no_run /// # extern crate serenity; + /// # /// # use self::serenity::model::id::ChannelId; + /// # + /// # #[cfg(feature = "model")] /// # fn main() { - /// # let channel = ChannelId(0).get().unwrap(); + /// # let channel = ChannelId(0).get().unwrap(); + /// # /// match channel.private() { /// Some(private_lock) => { /// let private = private_lock.read(); @@ -145,7 +165,11 @@ impl Channel { /// }, /// None => { println!("It's not a private channel!"); }, /// } + /// # /// # } + /// # + /// # #[cfg(not(feature = "model"))] + /// fn main() {} /// ``` pub fn private(self) -> Option<Arc<RwLock<PrivateChannel>>> { match self { @@ -166,16 +190,24 @@ impl Channel { /// /// ```rust,no_run /// # extern crate serenity; + /// # /// # use self::serenity::model::id::ChannelId; + /// # + /// # #[cfg(feature = "model")] /// # fn main() { /// # let channel = ChannelId(0).get().unwrap(); + /// # /// match channel.category() { /// Some(category_lock) => { /// println!("It's a category named {}!", category_lock.read().name); /// }, /// None => { println!("It's not a category!"); }, /// } + /// # /// # } + /// # + /// # #[cfg(not(feature = "model"))] + /// fn main() {} /// ``` pub fn category(self) -> Option<Arc<RwLock<ChannelCategory>>> { match self { @@ -674,8 +706,8 @@ pub enum PermissionOverwriteType { #[cfg(test)] mod test { - #[cfg(feature = "utils")] - mod utils { + #[cfg(all(feature = "model", feature = "utils"))] + mod model_utils { use model::prelude::*; use parking_lot::RwLock; use std::collections::HashMap; |