aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAustin Hellyer <[email protected]>2016-12-08 17:37:44 -0800
committerAustin Hellyer <[email protected]>2016-12-09 16:09:46 -0800
commitc7ffc4d4dd1ad63fae7a58f2299497aa3e3a39e7 (patch)
tree438143459a40d423f445647facc336895b2e4d79 /src
parentCommand builder, quoted args, and multi-prefixes (diff)
downloadserenity-c7ffc4d4dd1ad63fae7a58f2299497aa3e3a39e7.tar.xz
serenity-c7ffc4d4dd1ad63fae7a58f2299497aa3e3a39e7.zip
Fix some clippy lints
Diffstat (limited to 'src')
-rw-r--r--src/client/rest/mod.rs2
-rw-r--r--src/ext/cache/mod.rs12
-rw-r--r--src/model/channel.rs4
-rw-r--r--src/model/id.rs2
-rw-r--r--src/model/misc.rs6
5 files changed, 13 insertions, 13 deletions
diff --git a/src/client/rest/mod.rs b/src/client/rest/mod.rs
index 1ef59b8..97345fa 100644
--- a/src/client/rest/mod.rs
+++ b/src/client/rest/mod.rs
@@ -1438,7 +1438,7 @@ pub fn send_file<R: Read>(channel_id: u64,
let mut request = Multipart::from_request(request)?;
- request.write_stream("file", &mut file, Some(&filename), None)?;
+ request.write_stream("file", &mut file, Some(filename), None)?;
for (k, v) in map {
let val = match v {
diff --git a/src/ext/cache/mod.rs b/src/ext/cache/mod.rs
index 83ff46f..c09e1d8 100644
--- a/src/ext/cache/mod.rs
+++ b/src/ext/cache/mod.rs
@@ -413,12 +413,12 @@ impl Cache {
/// Retrieves a reference to a `User` based on appearance in
/// the first server they are in.
- pub fn get_user<U>(&self, user_id: U) -> Option<&User>
- where U: Into<UserId> + Clone {
- for v in self.guilds.values() {
- match v.members.get(&user_id.clone().into()) {
- Some(x) => { return Some(&x.user) }
- None => {}
+ pub fn get_user<U: Into<UserId>>(&self, user_id: U) -> Option<&User> {
+ let user_id = user_id.into();
+
+ for guild in self.guilds.values() {
+ if let Some(member) = guild.members.get(&user_id) {
+ return Some(&member.user);
}
}
diff --git a/src/model/channel.rs b/src/model/channel.rs
index 19f59ef..4ba31d6 100644
--- a/src/model/channel.rs
+++ b/src/model/channel.rs
@@ -656,7 +656,7 @@ impl Message {
}
}}
- let mut gen = format!("{}", self.author.mention());
+ let mut gen = self.author.mention();
gen.push_str(": ");
gen.push_str(content);
@@ -1197,7 +1197,7 @@ impl fmt::Display for ReactionType {
ReactionType::Custom { id, ref name } => {
f.write_char('<')?;
f.write_char(':')?;
- f.write_str(&name)?;
+ f.write_str(name)?;
f.write_char(':')?;
fmt::Display::fmt(&id, f)?;
f.write_char('>')
diff --git a/src/model/id.rs b/src/model/id.rs
index cbbd796..d0d0b61 100644
--- a/src/model/id.rs
+++ b/src/model/id.rs
@@ -176,7 +176,7 @@ impl UserId {
/// Search the cache for the channel with the Id.
#[cfg(all(feature = "cache", feature = "methods"))]
pub fn find(&self) -> Option<User> {
- CACHE.read().unwrap().get_user(*self).map(|x| x.clone())
+ CACHE.read().unwrap().get_user(*self).cloned()
}
}
diff --git a/src/model/misc.rs b/src/model/misc.rs
index e078bac..263362f 100644
--- a/src/model/misc.rs
+++ b/src/model/misc.rs
@@ -97,7 +97,7 @@ impl FromStr for User {
impl FromStr for UserId {
type Err = ();
fn from_str(s: &str) -> StdResult<Self, ()> {
- utils::parse_username(s).ok_or_else(|| ()).map(|x| UserId(x))
+ utils::parse_username(s).ok_or_else(|| ()).map(UserId)
}
}
@@ -120,7 +120,7 @@ impl FromStr for Role {
impl FromStr for RoleId {
type Err = ();
fn from_str(s: &str) -> StdResult<Self, ()> {
- utils::parse_role(s).ok_or_else(|| ()).map(|x| RoleId(x))
+ utils::parse_role(s).ok_or_else(|| ()).map(RoleId)
}
}
@@ -134,7 +134,7 @@ impl FromStr for EmojiIdentifier {
impl FromStr for ChannelId {
type Err = ();
fn from_str(s: &str) -> StdResult<Self, ()> {
- utils::parse_channel(s).ok_or_else(|| ()).map(|x| ChannelId(x))
+ utils::parse_channel(s).ok_or_else(|| ()).map(ChannelId)
}
}