diff options
| author | acdenisSK <[email protected]> | 2017-08-14 22:26:21 +0200 |
|---|---|---|
| committer | acdenisSK <[email protected]> | 2017-08-14 22:26:21 +0200 |
| commit | e00fe3ad9e1853443c8905da934ea3983813af89 (patch) | |
| tree | 2945905905b56526ec088966ca1db6732f46d0a0 | |
| parent | `$crate_name` => `version`, and a few adjustements (diff) | |
| download | serenity-e00fe3ad9e1853443c8905da934ea3983813af89.tar.xz serenity-e00fe3ad9e1853443c8905da934ea3983813af89.zip | |
Update examples
| -rw-r--r-- | examples/02_transparent_guild_sharding/src/main.rs | 2 | ||||
| -rw-r--r-- | examples/05_command_framework/src/main.rs | 6 | ||||
| -rw-r--r-- | examples/06_voice/src/main.rs | 8 | ||||
| -rw-r--r-- | examples/07_sample_bot_structure/src/commands/meta.rs | 1 |
4 files changed, 8 insertions, 9 deletions
diff --git a/examples/02_transparent_guild_sharding/src/main.rs b/examples/02_transparent_guild_sharding/src/main.rs index 0fd5a60..8546b0f 100644 --- a/examples/02_transparent_guild_sharding/src/main.rs +++ b/examples/02_transparent_guild_sharding/src/main.rs @@ -31,7 +31,7 @@ impl EventHandler for Handler { // multiple threads may otherwise attempt to read from or mutate it // concurrently. { - let shard = ctx.shard.lock().unwrap(); + let shard = ctx.shard.lock(); if let Some(shard_info) = shard.shard_info() { println!("Shard {}", shard_info[0]); diff --git a/examples/05_command_framework/src/main.rs b/examples/05_command_framework/src/main.rs index 467c4ab..c6c0fe4 100644 --- a/examples/05_command_framework/src/main.rs +++ b/examples/05_command_framework/src/main.rs @@ -42,7 +42,7 @@ fn main() { let mut client = Client::new(&token, Handler); { - let mut data = client.data.lock().unwrap(); + let mut data = client.data.lock(); data.insert::<CommandCounter>(HashMap::default()); } @@ -80,7 +80,7 @@ fn main() { // Increment the number of times this command has been run once. If // the command's name does not exist in the counter, add a default // value of 0. - let mut data = ctx.data.lock().unwrap(); + let mut data = ctx.data.lock(); let counter = data.get_mut::<CommandCounter>().unwrap(); let entry = counter.entry(command_name.clone()).or_insert(0); *entry += 1; @@ -148,7 +148,7 @@ fn main() { command!(commands(ctx, msg, _args) { let mut contents = "Commands used:\n".to_owned(); - let data = ctx.data.lock().unwrap(); + let data = ctx.data.lock(); let counter = data.get::<CommandCounter>().unwrap(); for (k, v) in counter { diff --git a/examples/06_voice/src/main.rs b/examples/06_voice/src/main.rs index 2faa207..70878ac 100644 --- a/examples/06_voice/src/main.rs +++ b/examples/06_voice/src/main.rs @@ -57,7 +57,7 @@ command!(deafen(ctx, msg) { }, }; - let mut shard = ctx.shard.lock().unwrap(); + let mut shard = ctx.shard.lock(); let handler = match shard.manager.get(guild_id) { Some(handler) => handler, @@ -103,7 +103,7 @@ command!(join(ctx, msg, args) { }, }; - let mut shard = ctx.shard.lock().unwrap(); + let mut shard = ctx.shard.lock(); shard.manager.join(guild_id, connect_to); check_msg(msg.channel_id.say(&format!("Joined {}", connect_to.mention()))); @@ -119,7 +119,7 @@ command!(leave(ctx, msg) { }, }; - let mut shard = ctx.shard.lock().unwrap(); + let mut shard = ctx.shard.lock(); let has_handler = shard.manager.get(guild_id).is_some(); if has_handler { @@ -141,7 +141,7 @@ command!(mute(ctx, msg) { }, }; - let mut shard = ctx.shard.lock().unwrap(); + let mut shard = ctx.shard.lock(); let handler = match shard.manager.get(guild_id) { Some(handler) => handler, diff --git a/examples/07_sample_bot_structure/src/commands/meta.rs b/examples/07_sample_bot_structure/src/commands/meta.rs index fc7c492..4b43cb8 100644 --- a/examples/07_sample_bot_structure/src/commands/meta.rs +++ b/examples/07_sample_bot_structure/src/commands/meta.rs @@ -1,6 +1,5 @@ command!(latency(ctx, msg) { let latency = ctx.shard.lock() - .unwrap() .latency() .map_or_else(|| "N/A".to_owned(), |s| { format!("{}.{}s", s.as_secs(), s.subsec_nanos()) |