aboutsummaryrefslogtreecommitdiff
path: root/src/utils
diff options
context:
space:
mode:
authorZeyla Hellyer <[email protected]>2017-12-16 13:24:09 -0800
committerZeyla Hellyer <[email protected]>2017-12-16 13:24:09 -0800
commit9b53582f5e5e9650abda4106124e7f9f4e78a90c (patch)
tree88bd56a75b1d110ea049abbaea88bb6e8a83dac3 /src/utils
parentFix compilation of examples (diff)
downloadserenity-9b53582f5e5e9650abda4106124e7f9f4e78a90c.tar.xz
serenity-9b53582f5e5e9650abda4106124e7f9f4e78a90c.zip
Fix most clippy lints, take more refeernces
Fix clippy lints and subsequently accept references for more function parameters.
Diffstat (limited to 'src/utils')
-rw-r--r--src/utils/message_builder.rs4
-rw-r--r--src/utils/mod.rs8
2 files changed, 6 insertions, 6 deletions
diff --git a/src/utils/message_builder.rs b/src/utils/message_builder.rs
index f94b3fd..b3599c2 100644
--- a/src/utils/message_builder.rs
+++ b/src/utils/message_builder.rs
@@ -162,7 +162,7 @@ impl MessageBuilder {
/// ```
///
/// [Display implementation]: ../model/struct.Emoji.html#method.fmt
- pub fn emoji(mut self, emoji: Emoji) -> Self {
+ pub fn emoji(mut self, emoji: &Emoji) -> Self {
let _ = write!(self.0, "{}", emoji);
self
@@ -171,7 +171,7 @@ impl MessageBuilder {
/// Mentions something that implements the [`Mentionable`] trait.
///
/// [`Mentionable`]: ../model/trait.Mentionable.html
- pub fn mention<M: Mentionable>(mut self, item: M) -> Self {
+ pub fn mention<M: Mentionable>(mut self, item: &M) -> Self {
let _ = write!(self.0, "{}", item.mention());
self
diff --git a/src/utils/mod.rs b/src/utils/mod.rs
index 2660798..907d3a3 100644
--- a/src/utils/mod.rs
+++ b/src/utils/mod.rs
@@ -18,7 +18,7 @@ use model::misc::EmojiIdentifier;
use std::collections::HashMap;
use std::ffi::OsStr;
use std::fs::File;
-use std::hash::Hash;
+use std::hash::{BuildHasher, Hash};
use std::io::Read;
use std::path::Path;
@@ -28,11 +28,11 @@ use cache::Cache;
use CACHE;
/// Converts a HashMap into a final `serde_json::Map` representation.
-pub fn hashmap_to_json_map<T>(map: HashMap<T, Value>) -> Map<String, Value>
- where T: Eq + Hash + ToString {
+pub fn hashmap_to_json_map<H, T>(map: HashMap<T, Value, H>)
+ -> Map<String, Value> where H: BuildHasher, T: Eq + Hash + ToString {
let mut json_map = Map::new();
- for (key, value) in map.into_iter() {
+ for (key, value) in map {
json_map.insert(key.to_string(), value);
}