Manually fix unnecessary_filter_map

rust
Elnu 1 year ago
parent 2e704dc90d
commit 24b87d9b78

@ -190,15 +190,17 @@ impl Database {
users
.iter()
// u64 must be converted to String for templates
.filter_map(|id| -> Option<Result<(String, User)>> {
.map(|id| -> Result<(String, User)> {
match conn.prepare("SELECT name, discriminator, avatar FROM User WHERE id = ?1") {
Ok(mut statement) => Some(statement.query_row(params![id], |row| Ok((id.to_string(), User {
id: *id,
name: row.get(0)?,
discriminator: row.get(1)?,
avatar: row.get(2)?,
}))).map_err(DatabaseError::Rusqlite)),
Err(error) => Some(Err(DatabaseError::Rusqlite(error))),
Ok(mut statement) => statement.query_row(params![id], |row| {
Ok((id.to_string(), User {
id: *id,
name: row.get(0)?,
discriminator: row.get(1)?,
avatar: row.get(2)?,
}))
}).map_err(|error| DatabaseError::Rusqlite(error)),
Err(error) => Err(DatabaseError::Rusqlite(error)),
}
})
.collect()

Loading…
Cancel
Save