diff --git a/src/main.rs b/src/main.rs index 2586cb7..83ceb74 100644 --- a/src/main.rs +++ b/src/main.rs @@ -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 () ; diff --git a/src/utility.rs b/src/utility.rs index 8dcca3e..fc922a0 100644 --- a/src/utility.rs +++ b/src/utility.rs @@ -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 ;