From 8614c33810b9406a4c117f04afa756eff05ab7a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matou=C5=A1=20Volf?= <66163112+matous-volf@users.noreply.github.com> Date: Mon, 9 Sep 2024 18:49:06 +0200 Subject: [PATCH] feat: implement `Ord` for the project model --- src/models/project.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) 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 {