summaryrefslogtreecommitdiff
path: root/src/db/mod.rs
diff options
context:
space:
mode:
authorKit La Touche <kit@transneptune.net>2024-10-23 21:56:31 -0400
committerKit La Touche <kit@transneptune.net>2024-10-23 21:56:31 -0400
commit1f769855df2d9cf2bca883a0475670f227e3678b (patch)
tree6c94d9c868eb022588a07245df978478034ac5dd /src/db/mod.rs
parent8f360dd9cc45bb14431238ccc5e3d137c020fa7b (diff)
parent461814e5174cef1be3e07b4e4069314e9bcbedd6 (diff)
Merge branch 'main' into wip/mobile
Diffstat (limited to 'src/db/mod.rs')
-rw-r--r--src/db/mod.rs15
1 files changed, 5 insertions, 10 deletions
diff --git a/src/db/mod.rs b/src/db/mod.rs
index 6005813..e0522d4 100644
--- a/src/db/mod.rs
+++ b/src/db/mod.rs
@@ -130,14 +130,17 @@ pub enum Error {
Rejected(String, String),
}
-pub trait NotFound {
+pub trait NotFound: Sized {
type Ok;
type Error;
fn not_found<E, F>(self, map: F) -> Result<Self::Ok, E>
where
E: From<Self::Error>,
- F: FnOnce() -> E;
+ F: FnOnce() -> E,
+ {
+ self.optional()?.ok_or_else(map)
+ }
fn optional(self) -> Result<Option<Self::Ok>, Self::Error>;
}
@@ -153,14 +156,6 @@ impl<T> NotFound for Result<T, sqlx::Error> {
Err(other) => Err(other),
}
}
-
- fn not_found<E, F>(self, map: F) -> Result<T, E>
- where
- E: From<sqlx::Error>,
- F: FnOnce() -> E,
- {
- self.optional()?.ok_or_else(map)
- }
}
pub trait Duplicate {