aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/model/guild.rs33
1 files changed, 33 insertions, 0 deletions
diff --git a/src/model/guild.rs b/src/model/guild.rs
index 7a3410f..6c5fab2 100644
--- a/src/model/guild.rs
+++ b/src/model/guild.rs
@@ -1,3 +1,4 @@
+use std::cmp::Ordering;
use std::collections::HashMap;
use std::fmt;
use super::utils::{
@@ -1099,3 +1100,35 @@ impl fmt::Display for Role {
fmt::Display::fmt(&self.mention(), f)
}
}
+
+impl Eq for Role {}
+
+impl Ord for Role {
+ fn cmp(&self, other: &Role) -> Ordering {
+ if self.position > other.position {
+ Ordering::Greater
+ } else if self.position == other.position {
+ if self.id > other.id {
+ Ordering::Greater
+ } else if self.id == other.id {
+ Ordering::Equal
+ } else {
+ Ordering::Less
+ }
+ } else {
+ Ordering::Less
+ }
+ }
+}
+
+impl PartialEq for Role {
+ fn eq(&self, other: &Role) -> bool {
+ self.id == other.id
+ }
+}
+
+impl PartialOrd for Role {
+ fn partial_cmp(&self, other: &Role) -> Option<Ordering> {
+ Some(self.cmp(other))
+ }
+}