Change to map
This commit is contained in:
parent
d60b70ffb4
commit
b806b28a6e
1 changed files with 6 additions and 9 deletions
|
|
@ -104,15 +104,12 @@ pub fn list_devices(user_id: i64) -> Result<Vec<String>> {
|
|||
let conn = rusqlite::Connection::open(PATH)?;
|
||||
let mut stmt = conn.prepare("SELECT name FROM device WHERE user_id = ?")?;
|
||||
|
||||
let devices = stmt.query_map([user_id], |row| {
|
||||
let result: Vec<String> = stmt
|
||||
.query_map([user_id], |row| {
|
||||
let name: String = row.get(0)?;
|
||||
Ok(name)
|
||||
})?;
|
||||
|
||||
let mut result = Vec::new();
|
||||
for device in devices {
|
||||
result.push(device?);
|
||||
}
|
||||
})?
|
||||
.collect::<Result<Vec<_>, _>>()?;
|
||||
|
||||
Ok(result)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue