diff --git a/src/models/project.rs b/src/models/project.rs index fb8da72..8dcd419 100644 --- a/src/models/project.rs +++ b/src/models/project.rs @@ -1,3 +1,4 @@ +use std::cmp::Ordering; use chrono::NaiveDateTime; use crate::schema::projects; use diesel::prelude::*; @@ -35,6 +36,20 @@ impl Project { } } +impl Eq for Project {} + +impl PartialOrd for Project { + fn partial_cmp(&self, other: &Self) -> Option { + Some(self.cmp(other)) + } +} + +impl Ord for Project { + fn cmp(&self, other: &Self) -> Ordering { + self.title().cmp(other.title()) + } +} + #[derive(Insertable, Serialize, Deserialize, Validate, Clone, Debug)] #[diesel(table_name = projects)] pub struct NewProject {