fix: implement Hash for Category manually
				
					
				
			This commit is contained in:
		| @@ -1,3 +1,4 @@ | ||||
| use std::hash::Hash; | ||||
| use crate::schema::tasks; | ||||
| use chrono::{Duration, NaiveDate, NaiveTime}; | ||||
| use diesel::deserialize::FromSql; | ||||
| @@ -11,7 +12,7 @@ use serde_with::DurationSeconds; | ||||
| use std::io::Write; | ||||
|  | ||||
| #[serde_with::serde_as] | ||||
| #[derive(AsExpression, FromSqlRow, Serialize, Deserialize, Hash, Clone, Debug)] | ||||
| #[derive(AsExpression, FromSqlRow, Serialize, Deserialize, Clone, Debug)] | ||||
| #[diesel(sql_type = Jsonb)] | ||||
| pub enum Category { | ||||
|     Inbox, | ||||
| @@ -45,6 +46,12 @@ impl Category { | ||||
|     } | ||||
| } | ||||
|  | ||||
| impl Hash for Category { | ||||
|     fn hash<H: std::hash::Hasher>(&self, state: &mut H) { | ||||
|         std::mem::discriminant(self).hash(state); | ||||
|     } | ||||
| } | ||||
|  | ||||
| impl PartialEq for Category { | ||||
|     fn eq(&self, other: &Self) -> bool { | ||||
|         std::mem::discriminant(self) == std::mem::discriminant(other) | ||||
|   | ||||
| @@ -13,7 +13,7 @@ pub(crate) fn use_tasks_in_category_query(category: Category) | ||||
|  | ||||
| async fn fetch_tasks_in_category(keys: Vec<QueryKey>) -> QueryResult<QueryValue, QueryErrors> { | ||||
|     if let Some(QueryKey::TasksInCategory(category)) = keys.first() { | ||||
|         match get_tasks_in_category(category.clone()).await {  | ||||
|         match get_tasks_in_category(category.clone()).await { | ||||
|             Ok(tasks) => Ok(QueryValue::Tasks(tasks)), | ||||
|             Err(ServerFnError::WrappedServerError(errors)) => Err(QueryErrors::Error(errors)), | ||||
|             Err(error) => panic!("Unexpected error: {:?}", error) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user