From: Jacob Casper Date: Tue, 20 Oct 2020 02:35:23 +0000 (-0500) Subject: Clone map so that it multiple closures can use it and implement FnMut X-Git-Url: https://git.jacobcasper.com/?p=xsetrootd.git;a=commitdiff_plain;h=166835308e0da192a1bb4857f1800e18cf3521c8 Clone map so that it multiple closures can use it and implement FnMut --- 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); } _ => (), }