aboutsummaryrefslogtreecommitdiff
path: root/examples/05_command_framework
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/05_command_framework
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/05_command_framework')
-rw-r--r--examples/05_command_framework/src/main.rs2
1 files changed, 1 insertions, 1 deletions
diff --git a/examples/05_command_framework/src/main.rs b/examples/05_command_framework/src/main.rs
index 437c44e..975e216 100644
--- a/examples/05_command_framework/src/main.rs
+++ b/examples/05_command_framework/src/main.rs
@@ -199,7 +199,7 @@ command!(about_role(_ctx, msg, args) {
if let Some(guild) = msg.guild() {
// `role_by_name()` allows us to attempt attaining a reference to a role
// via its name.
- if let Some(role) = guild.read().unwrap().role_by_name(&potential_role_name) {
+ if let Some(role) = guild.read().role_by_name(&potential_role_name) {
if let Err(why) = msg.channel_id.say(&format!("Role-ID: {}", role.id)) {
println!("Error sending message: {:?}", why);
}