Remove silent unwrap in data providers

This commit is contained in:
micialware committed 2026-08-19 23:37:59 +03:00
1 parent 01f0999772
commit de2dbaf6c1
6 files changed
+47 -64

No files matched your search

+13 -5
View File
@@ -30,17 +30,25 @@ fn parse_history_items(strings: Vec<String>) -> Vec<HistoryItem> {
let mut items = Vec::with_capacity(strings.len());
for string in strings {
if let [time, word, mode, before, after] = string.split(';').collect::<Vec<&str>>()[..] {
let id = word.parse::<Id>();
if id.is_err(){
continue;
}
let id = id.unwrap();
if !id.is_valid() {
continue;
}
items.push(HistoryItem {
timestamp: DateTime::from_timestamp(time.parse().unwrap(), 0).unwrap(),
word_id: word.parse::<Id>().unwrap(),
mode: match mode.parse::<u8>().unwrap() {
timestamp: DateTime::from_timestamp(time.parse().unwrap_or_default(), 0).unwrap(),
word_id: id,
mode: match mode.parse::<u8>().unwrap_or_default() {
2 => WordOpenMode::Hard,
3 => WordOpenMode::Ok,
4 => WordOpenMode::Easy,
_ => WordOpenMode::None,
},
before: before.parse().unwrap(),
after: after.parse().unwrap(),
before: before.parse().unwrap_or_default(),
after: after.parse().unwrap_or_default(),
});
}
}