From 24b87d9b78bd0c0a97afbb4ecc2efc59b7041fb6 Mon Sep 17 00:00:00 2001 From: ElnuDev Date: Fri, 30 Jun 2023 16:02:50 -0700 Subject: [PATCH] Manually fix unnecessary_filter_map --- src/models/database.rs | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/models/database.rs b/src/models/database.rs index 9ef1877..d8774c6 100644 --- a/src/models/database.rs +++ b/src/models/database.rs @@ -190,15 +190,17 @@ impl Database { users .iter() // u64 must be converted to String for templates - .filter_map(|id| -> Option> { + .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()