From 494b9b5424d6fa904e2d8c1638c8ce5109bac08e Mon Sep 17 00:00:00 2001 From: "Ivan A. Kudryavtsev" Date: Mon, 18 Jul 2022 12:56:27 +0400 Subject: [PATCH] drafted 0.16.0 improved api for nonblocking merging --- src/track/store.rs | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/src/track/store.rs b/src/track/store.rs index 225fa1f..4405ef9 100644 --- a/src/track/store.rs +++ b/src/track/store.rs @@ -222,11 +222,8 @@ where let dists = track.distances(other, feature_class); if let Err(e) = &dists { match e.downcast_ref::() { - None => Some(dists), - Some(e) => match e { - Errors::IncompatibleAttributes => None, - _ => Some(dists), - }, + Some(Errors::IncompatibleAttributes) => None, + _ => Some(dists), } } else { capacity += dists.as_ref().unwrap().len(); @@ -238,11 +235,8 @@ where let dists = track.distances(other, feature_class); if let Err(e) = &dists { match e.downcast_ref::() { - None => Some(dists), - Some(e) => match e { - Errors::IncompatibleAttributes => None, - _ => Some(dists), - }, + Some(Errors::IncompatibleAttributes) => None, + _ => Some(dists), } } else { capacity += dists.as_ref().unwrap().len(); @@ -280,15 +274,13 @@ where Some(dest) => { if dest_id == src.track_id { Err(Errors::SameTrackCalculation(dest_id).into()) + } else if !classes.is_empty() { + dest.merge(&src, &classes, merge_history) } else { - let res = if !classes.is_empty() { - dest.merge(&src, &classes, merge_history) - } else { - dest.merge(&src, &src.get_feature_classes(), merge_history) - }; - res + dest.merge(&src, &src.get_feature_classes(), merge_history) } } + None => Err(Errors::TrackNotFound(dest_id).into()), };