Use AsyncFn now that we're on Rust 2024

This commit is contained in:
Reinout Meliesie 2025-02-21 16:28:52 +01:00
parent a758dd113c
commit 4699e0de38
Signed by: zedfrigg
GPG key ID: 3AFCC06481308BC6
3 changed files with 3 additions and 13 deletions

View file

@ -48,7 +48,7 @@ fn show_window ( application : & Application ) {
let ui = UI :: new (
window ,
|film_uuid| pinned_async ! {
async |film_uuid| {
data_manager . get_film_details (film_uuid) . await
. expect ("A film with the given UUID should exist")
} ,

View file

@ -3,7 +3,6 @@ mod component ;
mod utility ;
use futures :: * ;
use futures :: future :: * ;
use gtk4 :: Orientation :: * ;
use gtk4 :: prelude :: * ;
use libadwaita :: * ;
@ -27,7 +26,7 @@ pub struct UI {
impl UI {
pub fn new (
window : & 'static Window ,
get_film_details : impl Fn (String) -> BoxFuture < 'static , FilmDetails > + 'static ,
get_film_details : impl AsyncFn (String) -> FilmDetails + 'static ,
) -> UI {
let get_film_details = leak (get_film_details) ;

View file

@ -20,19 +20,10 @@ pub fn leak_mut < 'l , Type > ( inner : Type ) -> & 'l mut Type {
Box :: leak ( Box :: new (inner) )
}
macro_rules ! pinned_async { (
$ ( $ async_expression : expr ) ; +
) => {
Box :: pin ( async {
$ ( $ async_expression ) ; +
} )
} }
pub fn to_os_string ( value : impl Display + Sized ) -> OsString {
OsString :: from ( ToString :: to_string ( & value ) )
}
pub (crate) use concat_os_str ;
pub (crate) use pinned_async ;
# [ allow (unused_imports) ] pub (crate) use concat_os_str ;