From 417a10ca5dbdd9db346566cafae2c5ef81406707 Mon Sep 17 00:00:00 2001 From: Jiahao XU Date: Sun, 19 Jun 2022 00:46:46 +1000 Subject: [PATCH] Always create `UIThreadInner` in `UIThread` Signed-off-by: Jiahao XU --- src/helpers/ui_thread.rs | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/helpers/ui_thread.rs b/src/helpers/ui_thread.rs index 7dbd6046..0d5e1aad 100644 --- a/src/helpers/ui_thread.rs +++ b/src/helpers/ui_thread.rs @@ -96,11 +96,8 @@ pub struct UIThread(Option); impl UIThread { /// * `enable` - `true` to enable confirmation, `false` to disable it. pub fn new(enable: bool) -> Self { - Self(if enable { - Some(UIThreadInner::new()) - } else { - None - }) + let ui_thread = UIThreadInner::new(); + Self(enable.then(|| ui_thread)) } pub async fn confirm(&mut self) -> Result<(), BinstallError> {