Skip to content

What to use as a minimal meaningless return type for a hook? #275

Answered by ilslv
fleetingbytes asked this question in Q&A
Discussion options

You must be logged in to vote

Cucumber::after hook receives a closure that has return type of Pin<Box<dyn Future + 'a>>, which basically means any Future allocated on the heap. This is done to support returned Futures of any stack size. From what I can see in your example, all code in the hook is synchronous (doesn't have .awaits) and you are trying to bridge synchronous and asynchronous code. I suggest doing it in 1 of 2 ways:

  1. Wrap your synchronous code into an async { ... } block and add .boxed_local() at the end:
#[tokio::main]
async fn main() {
    World::cucumber()
        .after(|_feature, _rule, _scenario, _event, world| async {
            //                                             ^^^^^
            /* m…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@fleetingbytes
Comment options

Answer selected by ilslv
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
question Further information is requested k::api Related to API (application interface)
2 participants