Introduce pinned_async macro
This commit is contained in:
parent
90594514bd
commit
a3040e6735
2 changed files with 16 additions and 3 deletions
|
@ -48,9 +48,10 @@ fn show_window ( application : & Application ) {
|
|||
|
||||
let ui = UI :: new (
|
||||
window ,
|
||||
|film_uuid| Box :: pin ( async {
|
||||
data_manager . get_film_details (film_uuid) . await . unwrap ()
|
||||
} ) ,
|
||||
|film_uuid| pinned_async ! {
|
||||
data_manager . get_film_details (film_uuid) . await
|
||||
. expect ("A film with the given UUID should exist")
|
||||
} ,
|
||||
) ;
|
||||
window . show () ;
|
||||
|
||||
|
|
|
@ -5,3 +5,15 @@ pub fn leak < 'l , Type > ( inner : Type ) -> & 'l Type {
|
|||
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 (crate) use pinned_async ;
|
||||
|
|
Loading…
Add table
Reference in a new issue