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>> {
|
pub fn get_player_from_req<T>(db: &Database, req: &CommandRequest<T>) -> Result<Option<Player>> {
|
||||||
if let Some(user_id) = &req.user {
|
if let Some(user_id) = &req.user {
|
||||||
Ok(db
|
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())
|
.next())
|
||||||
} else {
|
} else {
|
||||||
Ok(None)
|
Ok(None)
|
||||||
|
|
|
@ -35,13 +35,13 @@ impl From<serde_json::Error> for GeoffreyDBError {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Into<GeoffreyAPIError> for GeoffreyDBError {
|
impl From<GeoffreyDBError> for GeoffreyAPIError {
|
||||||
fn into(self) -> GeoffreyAPIError {
|
fn from(e: GeoffreyDBError) -> Self {
|
||||||
match self {
|
match e {
|
||||||
GeoffreyDBError::SledError(_) => GeoffreyAPIError::DatabaseError(self.to_string()),
|
GeoffreyDBError::SledError(_) => GeoffreyAPIError::DatabaseError(e.to_string()),
|
||||||
GeoffreyDBError::SerdeJsonError(_) => GeoffreyAPIError::DatabaseError(self.to_string()),
|
GeoffreyDBError::SerdeJsonError(_) => GeoffreyAPIError::DatabaseError(e.to_string()),
|
||||||
GeoffreyDBError::NotUnique => GeoffreyAPIError::EntryNotUnique,
|
GeoffreyDBError::NotUnique => GeoffreyAPIError::EntryNotUnique,
|
||||||
GeoffreyDBError::NotFound => GeoffreyAPIError::EntryNotFound
|
GeoffreyDBError::NotFound => GeoffreyAPIError::EntryNotFound,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue