aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/main.rs41
1 files changed, 23 insertions, 18 deletions
diff --git a/src/main.rs b/src/main.rs
index 2e3007c..85018c8 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -29,6 +29,16 @@ mod output;
mod filters;
+macro_rules! unwrap {
+ ($p:pat = $e:expr => { $r:expr} ) => {
+ if let $p = $e {
+ $r
+ } else {
+ panic!("Pattern match failed!");
+ }
+ };
+}
+
/// A program that allows you to search through all your evtc logs for specific
/// people.
#[derive(StructOpt, Debug)]
@@ -230,25 +240,20 @@ fn extract_info(entry: &DirEntry, log: &Log) -> LogResult {
let mut players = log
.players()
.map(|p| {
- if let AgentKind::Player { profession, elite } = p.kind() {
- if let AgentName::Player {
- account_name,
- character_name,
- subgroup,
- } = p.name()
- {
- Player {
- account_name: account_name.clone(),
- character_name: character_name.clone(),
- profession: get_profession_name(*profession, *elite).into(),
- subgroup: *subgroup,
- }
- } else {
- unreachable!()
+ unwrap! { AgentKind::Player { profession, elite } = p.kind() => {
+ unwrap! { AgentName::Player {
+ account_name,
+ character_name,
+ subgroup,
+ } = p.name() =>
+ {
+ Player {
+ account_name: account_name.clone(),
+ character_name: character_name.clone(),
+ profession: get_profession_name(*profession, *elite).into(),
+ subgroup: *subgroup,
}
- } else {
- unreachable!()
- }
+ }}}}
}).collect::<Vec<Player>>();
players.sort_by_key(|p| p.subgroup);