feat: implement Ord for the project model

This commit is contained in:
Matouš Volf 2024-09-09 18:49:06 +02:00
parent 6fd78a041f
commit 8614c33810

View File

@ -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<Self> for Project {
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
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 {