remove more unwrap
This commit is contained in:
1 parent
5a6747030b
commit
b5b1eb768c
6 files changed
+38
-26
No files matched your search
@@ -39,8 +39,8 @@ pub fn load_groups(connection: &Connection) -> Result<ImportData, NotificationDa
|
||||
|
||||
let counts = count_stmt
|
||||
.query_map([], |row| Ok((row.get(0)?, row.get(1)?)))
|
||||
.unwrap()
|
||||
.map(|x| x.unwrap())
|
||||
.map_err(|_| NotificationData::IncorrectAnkiFile)?
|
||||
.filter_map(|x| x.ok())
|
||||
.collect::<Vec<(i64, i64)>>();
|
||||
|
||||
for (_, collection) in sets {
|
||||
@@ -54,12 +54,12 @@ pub fn load_groups(connection: &Connection) -> Result<ImportData, NotificationDa
|
||||
.map(|x| x.as_str().unwrap().to_string())
|
||||
.collect();
|
||||
let id = collection.get("id");
|
||||
if id.is_none() {
|
||||
if id.is_none() || id.unwrap().as_u64().is_none(){
|
||||
return Err(NotificationData::IncorrectAnkiFile);
|
||||
}
|
||||
let id = id.unwrap().as_u64().unwrap();
|
||||
let name = collection.get("name");
|
||||
if name.is_none() {
|
||||
if name.is_none() || name.unwrap().as_str().is_none() {
|
||||
return Err(NotificationData::IncorrectAnkiFile);
|
||||
}
|
||||
let name = name.unwrap().as_str().unwrap().to_string();
|
||||
@@ -101,6 +101,6 @@ pub fn get_words_of_group(connection: &Connection, group_id: u64) -> Result<Vec<
|
||||
})
|
||||
})
|
||||
.map_err(|_| NotificationData::IncorrectAnkiFile)?
|
||||
.map(|x| x.unwrap())
|
||||
.filter_map(|x| x.ok())
|
||||
.collect::<Vec<ImportNote>>())
|
||||
}
|
||||
Reference in new issue
Block a user