pub trait NotFound { type Ok; fn not_found(self, map: F) -> Result where E: From, F: FnOnce() -> E; } impl NotFound for Result { type Ok = T; fn not_found(self, map: F) -> Result where E: From, F: FnOnce() -> E, { match self { Err(sqlx::Error::RowNotFound) => Err(map()), Err(other) => Err(other.into()), Ok(value) => Ok(value), } } }