Use AsyncFn now that we're on Rust 2024
This commit is contained in:
parent
a758dd113c
commit
4699e0de38
3 changed files with 3 additions and 13 deletions
|
@ -48,7 +48,7 @@ fn show_window ( application : & Application ) {
|
||||||
|
|
||||||
let ui = UI :: new (
|
let ui = UI :: new (
|
||||||
window ,
|
window ,
|
||||||
|film_uuid| pinned_async ! {
|
async |film_uuid| {
|
||||||
data_manager . get_film_details (film_uuid) . await
|
data_manager . get_film_details (film_uuid) . await
|
||||||
. expect ("A film with the given UUID should exist")
|
. expect ("A film with the given UUID should exist")
|
||||||
} ,
|
} ,
|
||||||
|
|
|
@ -3,7 +3,6 @@ mod component ;
|
||||||
mod utility ;
|
mod utility ;
|
||||||
|
|
||||||
use futures :: * ;
|
use futures :: * ;
|
||||||
use futures :: future :: * ;
|
|
||||||
use gtk4 :: Orientation :: * ;
|
use gtk4 :: Orientation :: * ;
|
||||||
use gtk4 :: prelude :: * ;
|
use gtk4 :: prelude :: * ;
|
||||||
use libadwaita :: * ;
|
use libadwaita :: * ;
|
||||||
|
@ -27,7 +26,7 @@ pub struct UI {
|
||||||
impl UI {
|
impl UI {
|
||||||
pub fn new (
|
pub fn new (
|
||||||
window : & 'static Window ,
|
window : & 'static Window ,
|
||||||
get_film_details : impl Fn (String) -> BoxFuture < 'static , FilmDetails > + 'static ,
|
get_film_details : impl AsyncFn (String) -> FilmDetails + 'static ,
|
||||||
) -> UI {
|
) -> UI {
|
||||||
let get_film_details = leak (get_film_details) ;
|
let get_film_details = leak (get_film_details) ;
|
||||||
|
|
||||||
|
|
|
@ -20,19 +20,10 @@ pub fn leak_mut < 'l , Type > ( inner : Type ) -> & 'l mut Type {
|
||||||
Box :: leak ( Box :: new (inner) )
|
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 {
|
pub fn to_os_string ( value : impl Display + Sized ) -> OsString {
|
||||||
OsString :: from ( ToString :: to_string ( & value ) )
|
OsString :: from ( ToString :: to_string ( & value ) )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
pub (crate) use concat_os_str ;
|
# [ allow (unused_imports) ] pub (crate) use concat_os_str ;
|
||||||
pub (crate) use pinned_async ;
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue