Cargo + Clippy
* Also discovered you can implement From<T> outside in modules outside whereT was declaredmain
parent
c2bc16f3d8
commit
c57738349b
|
@ -6,7 +6,7 @@ use geoffrey_models::models::player::Player;
|
|||
pub fn get_player_from_req<T>(db: &Database, req: &CommandRequest<T>) -> Result<Option<Player>> {
|
||||
if let Some(user_id) = &req.user {
|
||||
Ok(db
|
||||
.filter(|_, player: &Player| player.has_user_id(user_id)).map_err(|e| e.into())?
|
||||
.filter(|_, player: &Player| player.has_user_id(user_id))?
|
||||
.next())
|
||||
} else {
|
||||
Ok(None)
|
||||
|
|
|
@ -35,13 +35,13 @@ impl From<serde_json::Error> for GeoffreyDBError {
|
|||
}
|
||||
}
|
||||
|
||||
impl Into<GeoffreyAPIError> for GeoffreyDBError {
|
||||
fn into(self) -> GeoffreyAPIError {
|
||||
match self {
|
||||
GeoffreyDBError::SledError(_) => GeoffreyAPIError::DatabaseError(self.to_string()),
|
||||
GeoffreyDBError::SerdeJsonError(_) => GeoffreyAPIError::DatabaseError(self.to_string()),
|
||||
impl From<GeoffreyDBError> for GeoffreyAPIError {
|
||||
fn from(e: GeoffreyDBError) -> Self {
|
||||
match e {
|
||||
GeoffreyDBError::SledError(_) => GeoffreyAPIError::DatabaseError(e.to_string()),
|
||||
GeoffreyDBError::SerdeJsonError(_) => GeoffreyAPIError::DatabaseError(e.to_string()),
|
||||
GeoffreyDBError::NotUnique => GeoffreyAPIError::EntryNotUnique,
|
||||
GeoffreyDBError::NotFound => GeoffreyAPIError::EntryNotFound
|
||||
GeoffreyDBError::NotFound => GeoffreyAPIError::EntryNotFound,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue