From 84d4e100e93a5e3b630eaa355120871af46667d2 Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Thu, 16 Nov 2017 23:39:15 +0100 Subject: main(): Add comment above cloned command line variables Turns out the easiest way to share these variables between both closures really is to clone them. Thanks to 'durka42' on Mozilla#rust-beginners for explaining the problem to me. In durka's words: > both closures are required to be 'static > so you can't send references across > and the router handler has to be callable multiple times so you can't consume anything (that's the error you got) It's also possible to share references using Arc, but that seems more complicated than it's worth here. Just do the copy and be done with it. --- src/main.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/main.rs b/src/main.rs index c93d616..8c4fbfb 100644 --- a/src/main.rs +++ b/src/main.rs @@ -139,7 +139,9 @@ fn main() { }, }; - // TODO: Get rid of clones + // Clone so we can use these values in the thread + // closure. Since both closures are required to be + // 'static, we can't use references to these values. let jenkins_url = jenkins_url.clone(); let jenkins_user_id = jenkins_user_id.clone(); let jenkins_token = jenkins_token.clone(); -- cgit v1.2.3