aboutsummaryrefslogtreecommitdiff
path: root/examples/06_voice/src/main.rs
diff options
context:
space:
mode:
authorZeyla Hellyer <[email protected]>2017-10-10 20:08:11 -0700
committerZeyla Hellyer <[email protected]>2017-10-10 20:08:11 -0700
commit93e0a4215c915b98cf433ac6d0bcfbc60f0168ec (patch)
tree727111506d1f89cd8a511b8b79c102131222421f /examples/06_voice/src/main.rs
parentResume on resumable session invalidations (diff)
downloadserenity-93e0a4215c915b98cf433ac6d0bcfbc60f0168ec.tar.xz
serenity-93e0a4215c915b98cf433ac6d0bcfbc60f0168ec.zip
Switch to parking_lot::{Mutex, RwLock}
Switch to the `parking_lot` crate's implementations of `std::sync::Mutex` and `std::sync::RwLock`, which are more efficient. A writeup on why `parking_lot` is more efficient can be read here: <https://github.com/Amanieu/parking_lot> Upgrade path: Modify `mutex.lock().unwrap()` usage to `mutex.lock()` (not needing to unwrap or handle a result), and `rwlock.read().unwrap()`/`rwlock.write().unwrap()` usage to `rwlock.read()` and `rwlock.write()`. For example, modify: ```rust use serenity::CACHE; println!("{}", CACHE.read().unwrap().user.id); ``` to: ```rust use serenity::CACHE; println!("{}", CACHE.read().user.id); ```
Diffstat (limited to 'examples/06_voice/src/main.rs')
-rw-r--r--examples/06_voice/src/main.rs28
1 files changed, 14 insertions, 14 deletions
diff --git a/examples/06_voice/src/main.rs b/examples/06_voice/src/main.rs
index 8de2c3b..4c40bb4 100644
--- a/examples/06_voice/src/main.rs
+++ b/examples/06_voice/src/main.rs
@@ -49,8 +49,8 @@ fn main() {
}
command!(deafen(ctx, msg) {
- let guild_id = match CACHE.read().unwrap().guild_channel(msg.channel_id) {
- Some(channel) => channel.read().unwrap().guild_id,
+ let guild_id = match CACHE.read().guild_channel(msg.channel_id) {
+ Some(channel) => channel.read().guild_id,
None => {
check_msg(msg.channel_id.say("Groups and DMs not supported"));
@@ -95,8 +95,8 @@ command!(join(ctx, msg, args) {
},
};
- let guild_id = match CACHE.read().unwrap().guild_channel(msg.channel_id) {
- Some(channel) => channel.read().unwrap().guild_id,
+ let guild_id = match CACHE.read().guild_channel(msg.channel_id) {
+ Some(channel) => channel.read().guild_id,
None => {
check_msg(msg.channel_id.say("Groups and DMs not supported"));
@@ -111,8 +111,8 @@ command!(join(ctx, msg, args) {
});
command!(leave(ctx, msg) {
- let guild_id = match CACHE.read().unwrap().guild_channel(msg.channel_id) {
- Some(channel) => channel.read().unwrap().guild_id,
+ let guild_id = match CACHE.read().guild_channel(msg.channel_id) {
+ Some(channel) => channel.read().guild_id,
None => {
check_msg(msg.channel_id.say("Groups and DMs not supported"));
@@ -133,8 +133,8 @@ command!(leave(ctx, msg) {
});
command!(mute(ctx, msg) {
- let guild_id = match CACHE.read().unwrap().guild_channel(msg.channel_id) {
- Some(channel) => channel.read().unwrap().guild_id,
+ let guild_id = match CACHE.read().guild_channel(msg.channel_id) {
+ Some(channel) => channel.read().guild_id,
None => {
check_msg(msg.channel_id.say("Groups and DMs not supported"));
@@ -182,8 +182,8 @@ command!(play(ctx, msg, args) {
return Ok(());
}
- let guild_id = match CACHE.read().unwrap().guild_channel(msg.channel_id) {
- Some(channel) => channel.read().unwrap().guild_id,
+ let guild_id = match CACHE.read().guild_channel(msg.channel_id) {
+ Some(channel) => channel.read().guild_id,
None => {
check_msg(msg.channel_id.say("Error finding channel info"));
@@ -212,8 +212,8 @@ command!(play(ctx, msg, args) {
});
command!(undeafen(ctx, msg) {
- let guild_id = match CACHE.read().unwrap().guild_channel(msg.channel_id) {
- Some(channel) => channel.read().unwrap().guild_id,
+ let guild_id = match CACHE.read().guild_channel(msg.channel_id) {
+ Some(channel) => channel.read().guild_id,
None => {
check_msg(msg.channel_id.say("Error finding channel info"));
@@ -231,8 +231,8 @@ command!(undeafen(ctx, msg) {
});
command!(unmute(ctx, msg) {
- let guild_id = match CACHE.read().unwrap().guild_channel(msg.channel_id) {
- Some(channel) => channel.read().unwrap().guild_id,
+ let guild_id = match CACHE.read().guild_channel(msg.channel_id) {
+ Some(channel) => channel.read().guild_id,
None => {
check_msg(msg.channel_id.say("Error finding channel info"));