From 05a577d9a1c67ef718570e6e472e0ec879b661ed Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Leonard=20K=C3=B6nig?= <leonard.r.koenig@googlemail.com>
Date: Thu, 16 Jul 2020 12:37:14 +0200
Subject: [PATCH] Make callback subscription un-temporary

As we cannot just use the `?` operator anymore since `check_user_presence`
doesn't return a Tock error (cf. e1c6aca7), we need to create match of the result
which in turn moves it, thus we cannot use a temporary closure anymore but need
an assignment.
---
 src/main.rs | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/src/main.rs b/src/main.rs
index 18b4646..9a870c7 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -337,12 +337,15 @@ fn check_user_presence(cid: ChannelID) -> Result<(), Ctap2StatusCode> {
         Ok(x) => x,
         Err(err) => panic!("Couldn't init buttons subsystem"),
     };
-    let _buttons_callback = match buttons_driver.subscribe(&mut |_button_num, state| {
+
+    let mut subscription = |_button_num, state| {
         match state {
             ButtonState::Pressed => button_touched.set(true),
             ButtonState::Released => (),
         };
-    }) {
+    };
+    let _buttons_callback = buttons_driver.subscribe(&mut subscription);
+    let _buttons_callback = match _buttons_callback {
         Ok(x) => x,
         Err(err) => panic!("Couldn't subscribe to button"),
     };
-- 
GitLab