Remove many unwrap
This commit is contained in:
1 parent
39f8845119
commit
01f0999772
5 files changed
+40
-21
No files matched your search
+11
-4
@@ -3,7 +3,7 @@ use crate::data_provider::sqlite::{create_db, default_connection};
|
||||
use crate::data_provider::web_api::{
|
||||
get_local_version, get_web_version, load_data, set_local_version,
|
||||
};
|
||||
use crate::dictionary::{DictionaryMessage, DictionaryState, app_data_dir};
|
||||
use crate::dictionary::{app_data_dir, DictionaryMessage, DictionaryState};
|
||||
use crate::dictionary_test::{DictionaryQuizMessage, DictionaryQuizState};
|
||||
use crate::history::{HistoryMessage, HistoryState};
|
||||
use crate::import::{ImportMessage, ImportState};
|
||||
@@ -23,7 +23,7 @@ use crate::sync::{SyncMessage, SyncState};
|
||||
use crate::view_navigation;
|
||||
use crate::word::{WordMessage, WordState};
|
||||
use crate::writing::{WritingMessage, WritingState};
|
||||
use crate::{AppState, fill_state};
|
||||
use crate::{fill_state, AppState};
|
||||
use chrono::NaiveDate;
|
||||
use hashbrown::HashMap;
|
||||
use iced::keyboard::Event;
|
||||
@@ -126,7 +126,11 @@ impl ScreenState {
|
||||
let mut map = HashMap::new();
|
||||
for file in directory.read_dir().unwrap().flatten() {
|
||||
let mut vec = vec![];
|
||||
let history_file_name = file.file_name().into_string().unwrap();
|
||||
let history_file_name = match file.file_name().into_string() {
|
||||
Err(_) => continue,
|
||||
Ok(v) => v,
|
||||
};
|
||||
|
||||
let id: Id = history_file_name[4..history_file_name.len() - 12]
|
||||
.parse::<Id>()
|
||||
.unwrap();
|
||||
@@ -303,7 +307,10 @@ macro_rules! message_navigation {
|
||||
($msg:expr, $stack:expr, $state:expr) => {
|
||||
if let Some(new_page) = $state.navigate(&$msg) {
|
||||
if let Page::PreviousPage = new_page {
|
||||
$stack.pop();
|
||||
if $stack.len() > 1 {
|
||||
$stack.pop();
|
||||
}
|
||||
|
||||
return (Task::<RootMessage>::none(), true);
|
||||
} else {
|
||||
$stack.push(new_page);
|
||||
|
||||
Reference in new issue
Block a user