aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authoracdenisSK <[email protected]>2017-10-15 17:09:33 +0200
committeracdenisSK <[email protected]>2017-10-15 17:09:57 +0200
commitb7cdf1542cb9199c61c0b17bdd381d4f117f635e (patch)
treecdbf323c4c21fdb1028e89d63993478a7f4f2ced /src
parentUpdate URL to logo (diff)
downloadserenity-b7cdf1542cb9199c61c0b17bdd381d4f117f635e.tar.xz
serenity-b7cdf1542cb9199c61c0b17bdd381d4f117f635e.zip
Hash and do equality on just the id for `User`
Diffstat (limited to 'src')
-rw-r--r--src/model/user.rs18
1 files changed, 17 insertions, 1 deletions
diff --git a/src/model/user.rs b/src/model/user.rs
index 39efa10..c1c3135 100644
--- a/src/model/user.rs
+++ b/src/model/user.rs
@@ -343,7 +343,7 @@ impl Default for OnlineStatus {
}
/// Information about a user.
-#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Hash)]
+#[derive(Clone, Debug, Deserialize)]
pub struct User {
/// The unique Id of the user. Can be used to calculate the account's
/// cration date.
@@ -365,6 +365,22 @@ pub struct User {
pub name: String,
}
+use std::hash::{Hash, Hasher};
+
+impl PartialEq for User {
+ fn eq(&self, other: &Self) -> bool {
+ self.id == other.id
+ }
+}
+
+impl Eq for User {}
+
+impl Hash for User {
+ fn hash<H: Hasher>(&self, hasher: &mut H) {
+ self.id.hash(hasher);
+ }
+}
+
#[cfg(feature = "model")]
impl User {
/// Returns the formatted URL of the user's icon, if one exists.