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 conn = rusqlite::Connection::open(PATH)?;
|
||||||
let mut stmt = conn.prepare("SELECT name FROM device WHERE user_id = ?")?;
|
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
|
||||||
let name: String = row.get(0)?;
|
.query_map([user_id], |row| {
|
||||||
Ok(name)
|
let name: String = row.get(0)?;
|
||||||
})?;
|
Ok(name)
|
||||||
|
})?
|
||||||
let mut result = Vec::new();
|
.collect::<Result<Vec<_>, _>>()?;
|
||||||
for device in devices {
|
|
||||||
result.push(device?);
|
|
||||||
}
|
|
||||||
|
|
||||||
Ok(result)
|
Ok(result)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue