From 3db442fb8fae0f36c3771a77dcde1316f7eb52e4 Mon Sep 17 00:00:00 2001 From: Maximiliano Sandoval Date: Tue, 4 Mar 2025 15:40:46 +0100 Subject: [PATCH] async: accommodate to edition 2024 changes to RPIT Prevents the following error: ``` error[E0597]: `inner` does not live long enough --> proxmox-async/src/broadcast_future.rs:109:24 | 107 | inner: Arc>>, | ----- binding `inner` declared here 108 | ) -> impl Future> { 109 | let mut data = inner.lock().unwrap(); | ^^^^^ borrowed value does not live long enough ... 121 | data.broadcast.listen() | ----------------------- argument requires that `inner` is borrowed for `'static` 122 | } | - `inner` dropped here while still borrowed error[E0597]: `data` does not live long enough --> proxmox-async/src/broadcast_future.rs:121:9 | 109 | let mut data = inner.lock().unwrap(); | -------- binding `data` declared here ... 121 | data.broadcast.listen() | ^^^^------------------- | | | borrowed value does not live long enough | argument requires that `data` is borrowed for `'static` 122 | } | - `data` dropped here while still borrowed ``` The use<...> pattern was introduced in rust 1.82. Signed-off-by: Maximiliano Sandoval --- Cargo.toml | 2 +- proxmox-async/src/broadcast_future.rs | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index c526acef..3dbe595f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -62,7 +62,7 @@ license = "AGPL-3" repository = "https://git.proxmox.com/?p=proxmox.git" homepage = "https://proxmox.com" exclude = [ "debian" ] -rust-version = "1.80" +rust-version = "1.82" [workspace.dependencies] # any features enabled here are enabled on all members using 'workspace = true'! diff --git a/proxmox-async/src/broadcast_future.rs b/proxmox-async/src/broadcast_future.rs index 838204d3..62982e13 100644 --- a/proxmox-async/src/broadcast_future.rs +++ b/proxmox-async/src/broadcast_future.rs @@ -43,7 +43,7 @@ impl BroadcastData { } } - pub fn listen(&mut self) -> impl Future> { + pub fn listen(&mut self) -> impl Future> + use { use futures::future::{ok, Either}; match &self.result { @@ -105,7 +105,7 @@ impl BroadcastFuture { fn spawn( inner: Arc>>, - ) -> impl Future> { + ) -> impl Future> + use { let mut data = inner.lock().unwrap(); if let Some(source) = data.future.take() { @@ -122,7 +122,7 @@ impl BroadcastFuture { } /// Register a listener - pub fn listen(&self) -> impl Future> { + pub fn listen(&self) -> impl Future> + use { let inner2 = self.inner.clone(); async move { Self::spawn(inner2).await } }