From 166835308e0da192a1bb4857f1800e18cf3521c8 Mon Sep 17 00:00:00 2001 From: Jacob Casper Date: Mon, 19 Oct 2020 21:35:23 -0500 Subject: [PATCH] Clone map so that it multiple closures can use it and implement FnMut --- src/main.rs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/main.rs b/src/main.rs index 0a5eda3..da31c89 100644 --- a/src/main.rs +++ b/src/main.rs @@ -24,6 +24,7 @@ fn main() -> Result<(), Box> { Duration::from_millis(5000), ); + let spotify_match_map = arc_locked_xset_map.clone(); let _ = proxy.match_signal( move |pc: PropertiesPropertiesChanged, _: &Connection, _: &Message| { pc.changed_properties["Metadata"] @@ -35,19 +36,17 @@ fn main() -> Result<(), Box> { let key_str = key.as_str()?; let value = iter.next(); - let arc_locked_xset_map = Arc::clone(&arc_locked_xset_map); - match key_str { "xesam:artist" => { // Variant holding a variant that should just be a Vec<&str> I // believe. This is _the recommended_ way to do this by the author. let inner_value = value?.as_iter()?.next()?.as_iter()?.next()?; let artist = inner_value.as_str()?; - update_map(arc_locked_xset_map, "artist", artist); + update_map(spotify_match_map.clone(), "artist", artist); } "xesam:title" => { let title = value?.as_iter()?.next()?.as_str()?; - update_map(arc_locked_xset_map, "title", title); + update_map(spotify_match_map.clone(), "title", title); } _ => (), } -- 2.20.1