From 7d28106c2e8d11a9037c9b286c74fe81cf9f6193 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Fri, 10 Jul 2020 10:32:49 +0200 Subject: [PATCH] tutorials: Improve code of tutorial 3 a bit by removing unneeded downgrades and using closure parameters instead of capturing variables --- tutorials/src/bin/basic-tutorial-3.rs | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/tutorials/src/bin/basic-tutorial-3.rs b/tutorials/src/bin/basic-tutorial-3.rs index db692502f..c646cb387 100644 --- a/tutorials/src/bin/basic-tutorial-3.rs +++ b/tutorials/src/bin/basic-tutorial-3.rs @@ -32,23 +32,11 @@ fn tutorial_main() { .expect("Can't set uri property on uridecodebin"); // Connect the pad-added signal - let pipeline_weak = pipeline.downgrade(); - let convert_weak = convert.downgrade(); - source.connect_pad_added(move |_, src_pad| { - let pipeline = match pipeline_weak.upgrade() { - Some(pipeline) => pipeline, - None => return, - }; - - let convert = match convert_weak.upgrade() { - Some(convert) => convert, - None => return, - }; - + source.connect_pad_added(move |src, src_pad| { println!( "Received new pad {} from {}", src_pad.get_name(), - pipeline.get_name() + src.get_name() ); let sink_pad = convert