Skip to content

Commit

Permalink
Address some clippy warnings (#924)
Browse files Browse the repository at this point in the history
* Address warnings for `clippy::option_as_ref_deref`

The warnings were like this:

called `.as_ref().map(String::as_str)` on an Option value. This can be
done more directly by calling `query.as_deref()` instead

* Address warning for `clippy::iter_nth_zero`

The warning was like this:

called `.nth(0)` on a `std::iter::Iterator`
  • Loading branch information
Dany Marcoux authored Jul 29, 2020
1 parent 7dd01eb commit 2a54410
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/client/bridge/gateway/shard_runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ impl ShardRunner {
self.shard.chunk_guilds(
guild_ids,
limit,
query.as_ref().map(String::as_str),
query.as_deref(),
).is_ok()
},
ShardClientMessage::Runner(ShardRunnerMessage::Close(code, reason)) => {
Expand Down
2 changes: 1 addition & 1 deletion src/framework/standard/parse/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ fn to_lowercase<'a>(config: &Configuration, s: &'a str) -> Cow<'a, str> {
///
/// [`Configuration::on_mention`]: ../struct.Configuration.html#method.on_mention
pub fn mention<'a>(stream: &mut Stream<'a>, config: &Configuration) -> Option<&'a str> {
let on_mention = config.on_mention.as_ref().map(String::as_str)?;
let on_mention = config.on_mention.as_deref()?;

let start = stream.offset();

Expand Down
2 changes: 1 addition & 1 deletion src/model/channel/group.rs
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ impl Group {
match self.name {
Some(ref name) => Cow::Borrowed(name),
None => {
let mut name = match self.recipients.values().nth(0) {
let mut name = match self.recipients.values().next() {
Some(recipient) => recipient.with(|c| c.name.clone()),
None => return Cow::Borrowed("Empty Group"),
};
Expand Down

0 comments on commit 2a54410

Please sign in to comment.