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<Mutex<BroadCastFutureBinding<T>>>,
    |         ----- binding `inner` declared here
108 |     ) -> impl Future<Output = Result<T, Error>> {
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 <m.sandoval@proxmox.com>
This commit is contained in:
Maximiliano Sandoval 2025-03-04 15:40:46 +01:00 committed by Wolfgang Bumiller
parent 51c3a31115
commit 3db442fb8f
2 changed files with 4 additions and 4 deletions

View File

@ -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'!

View File

@ -43,7 +43,7 @@ impl<T: Clone> BroadcastData<T> {
}
}
pub fn listen(&mut self) -> impl Future<Output = Result<T, Error>> {
pub fn listen(&mut self) -> impl Future<Output = Result<T, Error>> + use<T> {
use futures::future::{ok, Either};
match &self.result {
@ -105,7 +105,7 @@ impl<T: Clone + Send + 'static> BroadcastFuture<T> {
fn spawn(
inner: Arc<Mutex<BroadCastFutureBinding<T>>>,
) -> impl Future<Output = Result<T, Error>> {
) -> impl Future<Output = Result<T, Error>> + use<T> {
let mut data = inner.lock().unwrap();
if let Some(source) = data.future.take() {
@ -122,7 +122,7 @@ impl<T: Clone + Send + 'static> BroadcastFuture<T> {
}
/// Register a listener
pub fn listen(&self) -> impl Future<Output = Result<T, Error>> {
pub fn listen(&self) -> impl Future<Output = Result<T, Error>> + use<T> {
let inner2 = self.inner.clone();
async move { Self::spawn(inner2).await }
}