mirror of
https://git.proxmox.com/git/proxmox
synced 2025-08-01 09:15:20 +00:00
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:
parent
51c3a31115
commit
3db442fb8f
@ -62,7 +62,7 @@ license = "AGPL-3"
|
|||||||
repository = "https://git.proxmox.com/?p=proxmox.git"
|
repository = "https://git.proxmox.com/?p=proxmox.git"
|
||||||
homepage = "https://proxmox.com"
|
homepage = "https://proxmox.com"
|
||||||
exclude = [ "debian" ]
|
exclude = [ "debian" ]
|
||||||
rust-version = "1.80"
|
rust-version = "1.82"
|
||||||
|
|
||||||
[workspace.dependencies]
|
[workspace.dependencies]
|
||||||
# any features enabled here are enabled on all members using 'workspace = true'!
|
# any features enabled here are enabled on all members using 'workspace = true'!
|
||||||
|
@ -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};
|
use futures::future::{ok, Either};
|
||||||
|
|
||||||
match &self.result {
|
match &self.result {
|
||||||
@ -105,7 +105,7 @@ impl<T: Clone + Send + 'static> BroadcastFuture<T> {
|
|||||||
|
|
||||||
fn spawn(
|
fn spawn(
|
||||||
inner: Arc<Mutex<BroadCastFutureBinding<T>>>,
|
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();
|
let mut data = inner.lock().unwrap();
|
||||||
|
|
||||||
if let Some(source) = data.future.take() {
|
if let Some(source) = data.future.take() {
|
||||||
@ -122,7 +122,7 @@ impl<T: Clone + Send + 'static> BroadcastFuture<T> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Register a listener
|
/// 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();
|
let inner2 = self.inner.clone();
|
||||||
async move { Self::spawn(inner2).await }
|
async move { Self::spawn(inner2).await }
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user