Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

stop_coroutine only accepts Coroutine<()> with a unit return type #885

Open
cancrizans opened this issue Jan 18, 2025 · 0 comments
Open

Comments

@cancrizans
Copy link

Following fails to compile on mquad 0.4.13:

use macroquad::experimental::coroutines::{start_coroutine,stop_coroutine};
async fn job_unit(){}
async fn job_u32() -> u32{42}
#[macroquad::main("stop_coroutine MWE")]
async fn main() {
    let coroutine_unit = start_coroutine(job_unit());
    stop_coroutine(coroutine_unit);
    let coroutine_u32 = start_coroutine(job_u32());
    stop_coroutine(coroutine_u32);
}

Message:

error[E0308]: mismatched types
   --> src/main.rs:9:20
    |
9   |     stop_coroutine(coroutine_u32);
    |     -------------- ^^^^^^^^^^^^^ expected `Coroutine`, found `Coroutine<u32>`
    |     |
    |     arguments to this function are incorrect
    |
    = note: expected struct `macroquad::experimental::coroutines::Coroutine<()>`
               found struct `macroquad::experimental::coroutines::Coroutine<u32>`

It seems like the reason is the omitted type param in the definition for stop_coroutine, but I'm not smart enough to figure out why that ends up setting it to unit instead of failing altogether.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant