aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDaniel <kingdread@gmx.de>2020-04-09 12:26:06 +0200
committerDaniel <kingdread@gmx.de>2020-04-09 12:27:06 +0200
commitd9b7433d168f3a5254e9bd10efd8c2875a3ff366 (patch)
tree35b77cf5ee5325477ade0b416df096584737e5d7 /src
parenta304370df4f998f7054731bac173113f91bf5cb1 (diff)
downloadraidgrep-d9b7433d168f3a5254e9bd10efd8c2875a3ff366.tar.gz
raidgrep-d9b7433d168f3a5254e9bd10efd8c2875a3ff366.tar.bz2
raidgrep-d9b7433d168f3a5254e9bd10efd8c2875a3ff366.zip
replace unwrap/match with if-let
Diffstat (limited to 'src')
-rw-r--r--src/filters.rs34
1 files changed, 14 insertions, 20 deletions
diff --git a/src/filters.rs b/src/filters.rs
index 715e4e4..cdd8f36 100644
--- a/src/filters.rs
+++ b/src/filters.rs
@@ -1,10 +1,10 @@
-use evtclib::{Agent, AgentName};
use evtclib::raw::parser::PartialEvtc;
use evtclib::statistics::gamedata::Boss;
+use evtclib::{Agent, AgentName};
use num_traits::FromPrimitive;
-use super::{SearchField, LogResult, Opt, guilds};
+use super::{guilds, LogResult, Opt, SearchField};
use chrono::Datelike;
@@ -12,22 +12,18 @@ use chrono::Datelike;
pub fn filter_name(evtc: &PartialEvtc, opt: &Opt) -> bool {
for player in &evtc.agents {
let fancy = Agent::from_raw(player);
- if fancy.is_err() {
- continue;
- }
- match fancy.unwrap().name() {
- AgentName::Player {
- ref account_name,
- ref character_name,
- ..
- } => {
- if (opt.field.contains(&SearchField::Account) && opt.expression.is_match(account_name))
- || (opt.field.contains(&SearchField::Character) && opt.expression.is_match(character_name))
- {
- return true;
- }
+ if let Ok(AgentName::Player {
+ ref account_name,
+ ref character_name,
+ ..
+ }) = fancy.as_ref().map(Agent::name)
+ {
+ if (opt.field.contains(&SearchField::Account) && opt.expression.is_match(account_name))
+ || (opt.field.contains(&SearchField::Character)
+ && opt.expression.is_match(character_name))
+ {
+ return true;
}
- _ => (),
}
}
// Don't throw away the log yet if we are searching for guilds
@@ -37,9 +33,7 @@ pub fn filter_name(evtc: &PartialEvtc, opt: &Opt) -> bool {
/// Do filtering based on the boss ID.
pub fn filter_boss(evtc: &PartialEvtc, opt: &Opt) -> bool {
let boss = Boss::from_u16(evtc.header.combat_id);
- boss
- .map(|b| opt.bosses.contains(&b))
- .unwrap_or(true)
+ boss.map(|b| opt.bosses.contains(&b)).unwrap_or(true)
}
/// Do filtering based on the fight outcome.